Again, that depends on where you are. Some possible choices are
12,345.6789 12.345,6789 12 345,6789
Some countries use a decimal point to separate the integer part of a number from the fractional part, others use a comma.
The default locale determines how DecimalFormat.format()
import java.text.*; class IODemoFloat { public static void main ( String[] args ) { double value = 12345.6789 ; DecimalFormat numform = new DecimalFormat(); System.out.println( "value = " + numform.format(value) ); } }
The output (on my computer) is:
value = 12,345.679
Notice that the output value has been rounded and shows three places to the right of the decimal.
Has the contents of the variable value
been changed
by format()
?