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) {

        // num is 3.141593
        System.out.printf("num is %f\n", Math.PI);
        // num is 3.14
        System.out.printf("num is %.2f\n", Math.PI);

    }

}
/*
num is 3.141593
num is 3.14
    
    
*/