Java.util.EnumMap.equals() 方法 Java.util.EnumMap.entrySet() 方法 Java.util.EnumMap.get() 方法 Java.util.EnumMap.equals() 方法 package com.codingdict; import java.util.*; public class EnumMapDemo { // create an enum public enum Numbers { ONE, TWO, THREE, FOUR, FIVE }; public static void main(String[] args) { EnumMap<Numbers, String> map1 = new EnumMap<Numbers, String>(Numbers.class); EnumMap<Numbers, String> map2 = new EnumMap<Numbers, String>(Numbers.class); // associate values in map1 map1.put(Numbers.ONE, "1"); map1.put(Numbers.TWO, "2"); map1.put(Numbers.THREE, "3"); map1.put(Numbers.FOUR, "4"); // associate values in map2 map2.put(Numbers.ONE, "1"); map2.put(Numbers.TWO, "2"); map2.put(Numbers.THREE, "3"); map2.put(Numbers.FOUR, "4"); // print the maps System.out.println("map1:" + map1); System.out.println("map2:" + map2); // check for equality between maps boolean equal = map1.equals(map2); // print the result System.out.println("Map1 and map 2 are equal:" + equal); // add one more value in map2 map2.put(Numbers.FIVE, "5"); // check for equality between maps equal = map1.equals(map2); // print the result System.out.println("Map1 and map 2 are equal:" + equal); } } Java.util.EnumMap.entrySet() 方法 Java.util.EnumMap.get() 方法