title: Best data structure to "group by" and aggregate values in Java?
body: <p>I created an ArrayList of Array type like below,</p>
  
  <pre><code>ArrayList&lt;Object[]&gt; csvArray = new ArrayList&lt;Object[]&gt;();
  </code></pre>
  
  <p>As you can see, each element of the ArrayList is an array like {Country, City, Name, Age}.</p>
  
  <p>Now I'm wanting to do a "<strong>group by</strong>" on <strong>Country</strong> and <strong>City</strong> (combined), followed by taking the <strong>average Age</strong> of the people for each Country+City.</p>
  
  <p>May I know what is the easiest way to achieve this? Or you guys have suggestions to use data structures better than ArrayList for this "group by" and aggregation requirements?</p>
  
  <p>Your answers are much appreciated.</p>