title: Enum equals() and ==
body: <pre><code>enum Drill{
          ATTENTION("Attention!"), AT_EASE("At Ease");    
          private String str; 
          private Drill(String str){
              this.str = str;
          }
          public String toString(){
              return str;
          }
      }
  public class EnumExample {
      public static void main(String[] args) {
              Drill d1= Drill.valueOf("ATTENTION");
              Drill d2= Drill.valueOf("ATTENTION");
              **System.out.println(d1.equals(d2));//TRUE
              System.out.println(d1==d2);//TRUE**
              System.out.println(Drill.ATTENTION.equals(Drill.valueOf("ATTENTION")));
              System.out.println(Drill.ATTENTION.equals(Drill.AT_EASE));//FALSE 
              System.out.println(Drill.ATTENTION==Drill.valueOf("ATTENTION"));//TRUE
              System.out.println(Drill.ATTENTION==Drill.AT_EASE);//FALSE
  }
  }
  </code></pre>
  
  <p>Enum behaviour while using == and equals() seems to be same. According to my knowledge, == just check references. Therefore d1 == d2 should be FALSE. Can anyone explain this behavior why is is TRUE? </p>