title: Looping through hashmap to group the values of same key into a <key, list<values>> pair
body: <p>I've been having a hard time trying to think of a way create a HashMap that groups values (into a list) that has the same key. This is what I mean:</p>
  
  <p>Say I have the following keys and values:</p>
  
  <pre><code>Value     Key  *Sorry I got the columns swapped
  1         10 
  1         11 
  1         12 
  2         20 
  3         30 
  3         31 
  </code></pre>
  
  <p>I would like to put these values into a </p>
  
  <pre><code>Hashmap &lt;Integer, List&lt;Integer&gt;&gt;
  </code></pre>
  
  <p>So that it will group the values into the List Integer that has the same key, something like this:</p>
  
  <p>(1, {10, 11, 12}),(2, {20}), (3, {30,31})</p>
  
  <p>Right now the key and the value are stored in a</p>
  
  <pre><code>Hashmap &lt;Integer, Integer&gt;
  </code></pre>
  
  <p>And I'm lost at how to loop through this Hashmap to create the new Hashmap with the key: List of Values pair. Does anyone have a good approach to this topic?</p>