1String prefix1 = "short text:";
2String prefix2 = "looooooooooooooong text:";
3String msg = "indented";
4/*
5* The second string begins after 40 characters. The dash means that the
6* first string is left-justified.
7*/
8String format = "%-40s%s%n";
9System.out.printf(format, prefix1, msg);
10System.out.printf(format, prefix2, msg);
11
12result:
13short text: indented
14looooooooooooooong text: indented
15