The easiest and simplest way would be using: Lamdaj grouping feature
The above example can be re-written:
List badGuys = Arrays.asList("Inky", "Blinky", "Pinky", "Pinky", "Clyde");
Group group = group(badGuys, by(on(String.class).length)));
System.out.println(group.keySet());