Your task is to produce a map of the frequencies of all letters in a string. Letters are represented as strings of length 1. For example, if you are given a string
Mary had a little lamb
you should produce the map
" " -> 4 "M" -> 1 "a" -> 4 "b" -> 1 "d" -> 1 "e" -> 1 "h" -> 1 "i" -> 1 "l" -> 3 "m" -> 1 "r" -> 1 "t" -> 2 "y" -> 1
Construct a map that contains the keys in sorted order.
Hint: Use autoboxing:
Integer f = freqs.get(letter); // Caution: may be null . . . freqs.put(letter, f + 1); // Can use arithmetic with Integer