title: How do I compare two enums?
body: <p>I have an enum named PawnColor which simply contains the following:</p>
  
  <pre><code>public enum PawnColor {
      black, white, none, illegal
  }
  </code></pre>
  
  <p>If I had the following method, how could I check the color of the current instance of PawnColor?</p>
  
  <pre><code>public double ratePosition (PawnColor ratingFor)  {
      // ...
  }
  </code></pre>
  
  <p>So if <code>ratingFor</code> had the color: <code>illegal</code>, how could I go about checking this? I've never worked with enums before, I feebly tried doing: </p>
  
  <pre><code>if(ratingFor.equals(illegal)) {
      System.out.println("Something has gone wrong.");
  }
  </code></pre>
  
  <p>It didn't work obviously, how would I make sure that I get an error message when PawnColor ratingFor is illegal?</p>