when i write float a=2; a=a+2; in C language then the output is 4.000000 ... but when i write the same code in java float a = 2F;
a=a+2;
then i got 4.0; why i m not getting the six zeros after the decimal like in c language
thanks
deepender sharma
Printable View
when i write float a=2; a=a+2; in C language then the output is 4.000000 ... but when i write the same code in java float a = 2F;
a=a+2;
then i got 4.0; why i m not getting the six zeros after the decimal like in c language
thanks
deepender sharma
Why not 7 zeros, or 8, or a hundred? How a number is displayed (especially trailing zeros) isn't really a "this language does it this way, why not this language?" issue. It might even be system dependent.
But anyway, what you're looking for is either the printf() function: PrintStream (Java Platform SE 6)
Or the DecimalFormat class: DecimalFormat (Java Platform SE 6)
can u tell me what is void in java ? what are modifiers and what System.out.print(); returns