PrintfExamples.java Source code

Java tutorial

Introduction

Here is the source code for PrintfExamples.java

Source

public class PrintfExamples {
    public static void main(String[] args) {
        System.out.printf("num is %03f\n", 3.14159265);
        System.out.printf("num is {%07.3f}\n", 3.14);
        System.out.printf("06.3 num is %06.3f\n", 3.14159265);
        System.out.printf(".3 num is %.3f\n", 3.14159265);
        System.out.printf("9.99 num is %4.2f\n", 9.999999999);

    }

}
/*
num is 3.141593
num is {003.140}
06.3 num is 03.142
.3 num is 3.142
9.99 num is 10.00
    
 */