public static void groupByLastNameOldWay(List<Person> people) {
//before Guava - 9 lines
Map<String, Collection<Person>> peopleForLastName = new HashMap<String, Collection<Person>>();
for (Person p : people) {
List<Person> peopleWithLastName = peopleForLastName.get(p.getLast());
if (peopleWithLastName == null) {
peopleWithLastName = new ArrayList<Person>();
peopleForLastName.put(p.getLast(), peopleWithLastName);
}
peopleWithLastName.add(p);
}
//peopleForLastName.get("Smith") will return Collection<Person>
}