Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to right align in java

// - defaults the argument to the left
// + defaults the argument to the right 
System.out.printf("%-40s%1s%n", "Far left", "Far right");

// Breakdown
// %-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
 
PREVIOUS NEXT
Tagged: #align #java
ADD COMMENT
Topic
Name
7+2 =