how to print alignment in java

www‮ual.‬tturi.com
how to print alignment in java
    • defaults the argument to the left
    • defaults the argument to the right
System.out.printf("%-40s%1s%n", "Far left", "Far right");

// %-40s creates a string field of forty characters, defaulting argument left.
// %+1s creates a string field of one character, defaulting argument right.
// %n creates a line break
Created Time:2017-09-13 15:55:07  Author:lautturi