java.lang.Enum.equals()


java.lang.Enum.equals()

package com.codingdict;



import java.lang.*;



// enum showing topics covered under Tutorials

enum Tutorials {  

   topic1, topic2, topic3;

} 



public class EnumDemo { 



   public static void main(String args[]) {



      Tutorials t1, t2, t3; 



      t1 = Tutorials.topic1; 

      t2 = Tutorials.topic2; 

      t3 = Tutorials.topic3; 



      if(t1.equals(t2)) {

         System.out.println(t1 + " is equal to " + t2); 

      } else if(t2.equals(t3)) {

         System.out.println(t2 + " is equal to " + t3); 

      } else if(t1.equals(t3)) { 

         System.out.println(t1 + " is equal to " + t3); 

      } else {

         System.out.println("all 3 topics are different"); 

      }

   } 

}