title: HashMap<String, Student> searching for instance in Student class
body: <p>I am working with two helper classes (Student, Helper), as well as a main class. </p>
  
  <p>In the Student class, I have the following constructor:</p>
  
  <pre><code>Student(String iName, String iMajor, int iNumber) {
      name = iName;
      major = iMajor;
      number = iNumber;
  }
  </code></pre>
  
  <p>In the Helper class, I declare a HashMap as follows: </p>
  
  <pre><code>HashMap&lt;String, Student&gt; students = new HashMap&lt;String, Student&gt;();
  </code></pre>
  
  <p>Now, I have written a few method for adding (put) new students into the HashMap construction, as well as a method for retrieving information about a student based on the name. </p>
  
  <pre><code>//Adding new students
  Student s1 = new Student("Alex", "Biology", 19);
  Student s2 = new Student("Brian", "Chemistry", 20);
  Student s3 = new Student("Tom", "Biology", 20);
  //etc...
  
  //Get student from name (key)
  public Student getFromKey(String key) {
      return students.get(key);
  }
  </code></pre>
  
  <p>I am now looking to write a method that finds all students based on either major or number. For instance, the call: </p>
  
  <pre><code>helper.getStudents("Biology");
  </code></pre>
  
  <p>Should return all the students studying Biology. I imagine the method looking something like:</p>
  
  <pre><code>public Student getStudents(String searchItem) {
      for(Students st : students.values()) {
          if(searchItem.equals(??)) {
              return st;
  //Something like this. 
  </code></pre>
  
  <p>However, I can't seem to figure out how to access these values. All the classes have appropriate getter and setter methods, and the program works fine. Any help is highly appreciated!</p>