Use Formatter to left-justify strings within a table.
import java.util.Formatter;
public class Main {
public static void main(String args[]) {
Formatter fmt = new Formatter();
fmt.format("%-12s %12s\n\n", "Source", "Loss");
fmt.format("%-12s %,12d\n", "Retail", 1232675);
System.out.println(fmt);
}
}
/*
Source Loss
Retail 1,232,675
*/
Related examples in the same category