title: Retrieving objects from HashMap in Java?
body: <p>I have a HashMap which holds studentIds as key and student objects as values,  </p>
  
  <pre><code>HashMap&lt;Integer, Student&gt; hashMap = hashTables.buildHash(students);
  
  public static HashMap&lt;Integer, Student&gt; buildHash(Student[] students) {
              HashMap&lt;Integer, Student&gt; hashMap = new HashMap&lt;Integer, Student&gt;();
              for (Student s : students) hashMap.put(s.getId(), s);
              return hashMap;
         }
  </code></pre>
  
  <p>the below code gets each KeyValue pair and s.getValue() returns a student object which is comprised of an id and an string name, how can i retrieve/print those values (student.int, student.name);</p>
  
  <pre><code>for(Map.Entry s : hashMap.entrySet())
      System.out.print(s.getKey()+" "+s.getValue());
  </code></pre>