I'm trying to group Java objects by their field, i.e Person.java
public class Person {
String name;
String surname;
....
}
So if I have n Person objects, what would be the easiest way to get all people name "David" into a map like Map<String, List<Person>> map;
?
I found this on Google (but it doesn't compile), it seems to be the thing I'm looking for: http://www.anzaan.com/2010/06/grouping-objects-using-objects-property/