Group by field name in java
<p>I'm trying to group java objects by their field i.e Person.java </p>

<pre><code>public class Person{
    String name;
    String surname;
    ....
}
</code></pre>

<p>So if I have n Person objects, what would be the easiest way to get all people name "David" into a map like <code>Map&lt;String, List&lt;Person&gt;&gt; map;</code> I found this on google but it doesn't compile it seems to be the thing I'm looking for :</p>

<p><a href="http://www.anzaan.com/2010/06/grouping-objects-using-objects-property/" rel="nofollow">http://www.anzaan.com/2010/06/grouping-objects-using-objects-property/</a></p>
