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("String is '%5s'\n", "A");
        System.out.printf("String is '%-5s'\n", "A");
        System.out.printf("String is '%.5s'\n", "Happy Birthday!");

    }

}
/*
String is '    A'
String is 'A    '
String is 'Happy'
    
    
*/