title: OnePair Pokerhand method java
body: <p>I am trying to figure out why my code isn't working. trying to create a pokerhand program for school and am trying to write the one pair method. I have to return a boolean. not sure why the count variable returns such a high value if I my array has numbers 2,2,3,4,5.</p>
  
  <pre><code>public static boolean containsPair(int [] hand)  
  {
    boolean pair = false;
    int count = 1;
    for(int i = 0; i &lt; 5; i++)
    {
      for(int j = 1; j &lt; 5; j++)
      {
        if (hand[i] == hand[j])
        count++;
  
      }
  
    }
    System.out.println(count);
    if (count == 2)
    pair = true;
    return pair;
  </code></pre>