title: Iterate through TreeMap - Return a set of all values of the keys of the map
body: <p>I have a database that maps course names to student id numbers. I need to iterate through the map to create another set that contains all students in the database. This is the code I have so far. Any help would be greatly appreciated!!</p>
  
  <p>//return a set of all students in the school</p>
  
  <pre><code>public Set&lt;Integer&gt; allStudents() {
     Set&lt;Map.Entry&lt;String,Set&lt;Integer&gt;&gt;&gt; entries = database.entrySet();
     Set&lt;Integer&gt; students = new TreeSet&lt;Integer&gt;();
  
     for (Map.Entry&lt;String,Set&lt;Integer&gt;&gt; pair: entries){ 
         students.add();
      }
  
      return students;
  
  } // end allStudents
  </code></pre>