title: Java - determining is Poker Hand has a Pair
body: <p>I'm trying to evaluate a hand to see if they have a pair and I feel like this is right but i keep getting errors. Any idea on what im doing wrong?</p>
  
  <pre><code>public boolean isPair() {
      String[] values = new String[5];
      int counter = 0;    
  
      //Put each cards numeric value into array
      for(int i = 0; i &lt; cards.length; i++){
          values[i] = cards[i].toString();
      }
  
      //Loop through the values. Compare each value to all values
      //If exactly two matches are made - return true
      for(int j = 0; j &lt; values.length; j++){
          for(int k = 0; k &lt; cards.length; k++){
              if(values[j].equals(cards[k].toString()))
                  counter++;
              if(counter == 2)
                  return true;
  
          }
          counter = 0;
      }
  
      return false;  
  }
  </code></pre>