title: Hashmap NoSuchElementException error
body: <p>I've been struggling with an java.util.NoSuchElementException error when I execute printAll. </p>
  
  <pre><code>public class myDatabase {
  
      Map&lt;String, HashSet&lt;Integer&gt;&gt; mapOfSets = new HashMap&lt;String, HashSet&lt;Integer&gt;&gt;();
  
      void printAll() {
  
          if (mapOfSets.isEmpty() == false)
          {
                  for (String key : mapOfSets.keySet()) 
                  {
                      System.out.println(key);
  
                      //print the set
                      for (HashSet&lt;Integer&gt; id : mapOfSets.values() ) 
                          System.out.println(id);
                  }
          }
  
  }
  </code></pre>
  
  <p>//rest of empty code...</p>
  
  <p><strong>Update from comments: The exception is</strong></p>
  
  <pre><code>java.util.NoSuchElementException 
  at java.util.HashMap$HashIterator.nextEntry(HashMap.java:809) 
  at java.util.HashMap$KeyIterator.next(HashMap.java:841) 
  at StudentDatabase.report(myDatabase.java:29) 
  at DatabaseRun1.main(DatabaseRun1.java:52)
  </code></pre>