double value = 1623542.765; NumberFormat numberFormatter; String formattedValue; numberFormatter = NumberFormat.getNumberInstance(); formattedValue = numberFormatter.format(value); System.out.format("%s%n", formattedValue);
In most applications, there is a need to display numbers. Fortunately, Java has built-in support for formatting numbers so that they will look as you want them to when you display them in your application.
This phrase will generate the following formatted number as output:
In this phrase, we use the NumberFormat class to format a double value into a comma separated string representation of its value. The NumberFormat class is found in the java.text package and is also very useful for code that ...