Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.text.NumberFormat;

public class Main {
    public static void main(String[] argv) throws Exception {

        NumberFormat nf = NumberFormat.getInstance();

        nf.setMinimumFractionDigits(2);

        System.out.println("Format with two decimal places: " + nf.format(1234567.678));
        System.out.println("Format with two decimal places: " + nf.format(1234567.6));

    }
}