java - Formatting a double to 2 decimal places - compilation error -


i'm trying format double 2 decimal places in program i'm writing.

i have

import java.text.decimalformat; public class testd {     double d = 1.234567;     decimalformat df = new decimalformat("#.##");      system.out.println(df.format(d));​ } 

could tell me i'm going wrong?

this line giving me errors:

system.out.println(df.format(d));​ 

you need put system.out.println method or in block compile. run need main method.

public class test { // class name should start capital   public static void main(string[] arg){   double d = 1.234567;   decimalformat df = new decimalformat("#.##");    system.out.println(df.format(d));​  } } 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -