EnumMap.equals(Object o) has the following syntax.
public boolean equals(Object o)
In the following code shows how to use EnumMap.equals(Object o) method.
/* w w w.j av a 2 s .co m*/ import java.util.*; enum Tutorial { CSS, Python, PHP, Java, Javascript }; public class Main { public static void main(String[] args) { EnumMap<Tutorial, String> map1 = new EnumMap<Tutorial, String> (Tutorial.class); EnumMap<Tutorial, String> map2 = new EnumMap<Tutorial, String> (Tutorial.class); map1.put(Tutorial.CSS, "1"); map1.put(Tutorial.Python, "2"); map1.put(Tutorial.PHP, "3"); map1.put(Tutorial.Java, "4"); map2.put(Tutorial.CSS, "1"); map2.put(Tutorial.Python, "2"); map2.put(Tutorial.PHP, "3"); map2.put(Tutorial.Java, "4"); System.out.println("map1:" + map1); System.out.println("map2:" + map2); boolean equal = map1.equals(map2); System.out.println("Map1 and map 2 are equal:" + equal); map2.put(Tutorial.Javascript, "5"); equal = map1.equals(map2); System.out.println("Map1 and map 2 are equal:" + equal); } }
The code above generates the following result.