Enum.equals(Object other) has the following syntax.
public final boolean equals(Object other)
In the following code shows how to use Enum.equals(Object other) method.
/*from ww w.java2s . c om*/ enum Tutorial { HTML, CSS, Java; } public class Main { public static void main(String args[]) { Tutorial t1 = Tutorial.HTML; Tutorial t2 = Tutorial.CSS; Tutorial t3 = Tutorial.Java; 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"); } } }
The code above generates the following result.