title: Searching through a collection of an array list pair
body: <p>I am trying to search through a collection of an ArrayList if pairs. What I want to be able to do, is to go through the collection and find the first value in a pair and return the second value of that pair. The problem I am having is that the check I have to find the first value doesn't seem to be working, so every time I search, I end up returning null. I know that the problem exists with my if statement, but I cannot seem to sort out what it is I am doing wrong. Since this is a homework assignment, I can't show all the code to my pair class, or my pair list class, but I can show you the method I have for searching the first value:</p>
  
  <pre><code>public S findFirst(F firstValue) {
      Iterator&lt;Pair&gt; myIter = this.iterator();
      S tmp2 = null;
      while (myIter.hasNext()) {
          Pair tmp1 = myIter.next();
          if (tmp1.getFirst() == firstCall) {
              tmp2 = (S) tmp1.getSecond();
          }
      }
      return tmp2;
  }
  </code></pre>
  
  <p>If I throw in an else statement that just calls what I am attempting to do in my if check, like this:</p>
  
  <pre><code>else{
             tmp2 = (S) tmp1.getSecond(); 
          }
  </code></pre>
  
  <p>then whenever I test for the first value, I get the second value, so I know I am at least on the correct path, but I am assuming that I am doing something wrong with what I am checking for in my if statement. Does anyone know how I can correctly do this, (and please bear in mind that this is homework, so a guide to how to figure this out is far more valuable to me than just some random answer, I want to learn, not just be given an answer) Thanks in advance!</p>