title: Get Key value from iterator
body: <p>I have a HashMap, which contains another HashMap. I want to iterate over the first HashMap and use the Key values from that. Then, as I iterate over the first HashMap I want to start an inner loop iterating over the second HashMap, getting all the values.</p>
  
  <p>The problem I have so far is that I can't figure out how to get the keys from the Iterator.</p>
  
  <pre><code>HashMap&lt;String, HashMap&lt;Integer, String&gt;&gt; subitems = myHashMap.get("mainitem1");
  
  Collection c = subitems.values();
  Iterator itr = c.iterator();
  
  while(itr.hasNext())
  {
      // Get key somehow? itr.getKey() ???
  
      // contains the sub items
      HashMap productitem = (HashMap)itr.next();
  }
  </code></pre>
  
  <p>The data that i get from <code>subitems</code> is this:</p>
  
  <pre><code>{Item1{0=sub1, 1=sub2}, Item2{0=sub3, 1=sub4}}
  </code></pre>
  
  <p>Then, in the while loop <code>productitem</code> contains the 'sub items'. But i can't find out where i can get the key value 'Item1' and 'Item2' from.</p>
  
  <p>How can i get those?</p>