import java.text.DecimalFormat; import java.text.NumberFormat; public class NumberFormat1 { public static void main(String[] args) { // By default, the 'toString' method of the 'Double' data type will // display values greater than 10^7 (10,000,000.00) using scientific // notation; to display the number in non-scientific notation format, // the 'DecimalFormat' class (which is a subclass of the 'NumberFormat' // class) can be used double money = 100550000.75; // In 'DecimalFormat' patterns, before the decimal point, the "#" // character will display any number, but leading zeros will not be // displayed; the "0" character will display the remaining digits, // and they will each display as zero if no digit is available; // after the decimal point, the "#" character will not display // trailing zeros, and will round, if necessary; the "0" character // will display a zero for each digit that is not available, and // will round, if necessary; when used before the decimal point, "#" // represents any number of digits, while "0" represents a single // digit; however, a longer number will not be cut short, even if // too few zeros exist before the decimal point NumberFormat formatter = new DecimalFormat("#0.00"); // Display the value using scientific notation System.out.println(money); // Display the value using the 'DecimalFormat' pattern defined above System.out.println(formatter.format(money)); } }