Java tutorial
/** * Output: Word Length a 1 aaa 3 aaaaaaaaaa 35 */ public class MainClass { public static void main(String args[]) throws Exception { String[] words = new String[] { "a", "aaa", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }; System.out.printf("%-10s %s\n", "Word", "Length"); for (String word : words) System.out.printf("%-10.10s %s\n", word, word.length()); } }