Menu
Question Index
...

What is the output of the following program?

import java.text.*;
public class DecimalFormatTest {
    public static void main(String[] args) {
        customFormat("###,###.###", 123456.789);
        customFormat("###.##", 123456.789);
        customFormat("000000.000", 123.78);
        customFormat("$###,###.###", 12345.67);
    }
     public static void customFormat(String pattern, double value) {
        DecimalFormat myFormatter = new DecimalFormat(pattern);
        System.out.print(myFormatter.format(value) + " - ");
    }
}


123,456.789 - 123456.79 - 000123.780 - $12,345.67 -
123,456.789 - 123456.79 - 000123.780 - $123,456.789 -
123,456.789 - 123456.78 - 000123.780 - $12,345.67 -
123,456.789 - 123456.79 - 123456.789 - $123,456.789 -

Doubts

Problems

Topic: Other Advanced Topics In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App