List of usage examples for java.util EnumMap EnumMap
public EnumMap(Map<K, ? extends V> m)
From source file:Main.java
public static void main(String[] args) { EnumMap<Size, String> sizeMap = new EnumMap<Size, String>(Size.class); sizeMap.put(Size.S, "S"); sizeMap.put(Size.M, "M"); sizeMap.put(Size.L, "L"); sizeMap.put(Size.XL, "XL"); sizeMap.put(Size.XXL, "XXL"); sizeMap.put(Size.XXXL, "XXXL"); for (Size size : Size.values()) { System.out.println(size + ":" + sizeMap.get(size)); }/* ww w .j ava 2s . c om*/ }
From source file:Tutorial.java
public static void main(String[] args) { EnumMap<Tutorial, String> map = new EnumMap<Tutorial, String>(Tutorial.class); map.put(Tutorial.CSS, "1"); map.put(Tutorial.Python, "2"); map.put(Tutorial.PHP, "3"); map.put(Tutorial.Java, "4"); System.out.println(map.hashCode()); }
From source file:Tutorial.java
public static void main(String[] args) { EnumMap<Tutorial, String> map = new EnumMap<Tutorial, String>(Tutorial.class); map.put(Tutorial.CSS, "1"); map.put(Tutorial.Python, "2"); map.put(Tutorial.PHP, "3"); map.put(Tutorial.Java, "4"); System.out.println(map);//from w ww.j av a 2 s. com map.remove(Tutorial.PHP); System.out.println("Updated Map: " + map); }
From source file:Tutorial.java
public static void main(String[] args) { EnumMap<Tutorial, String> map = new EnumMap<Tutorial, String>(Tutorial.class); map.put(Tutorial.CSS, "1"); map.put(Tutorial.Python, "2"); map.put(Tutorial.PHP, "3"); map.put(Tutorial.Java, "4"); System.out.println(map);/*w w w . j a v a 2 s. com*/ Set<Map.Entry<Tutorial, String>> set = map.entrySet(); System.out.println("Set: " + set); }
From source file:Tutorial.java
public static void main(String[] args) { EnumMap<Tutorial, String> map = new EnumMap<Tutorial, String>(Tutorial.class); map.put(Tutorial.CSS, "1"); map.put(Tutorial.Python, "2"); map.put(Tutorial.PHP, "3"); map.put(Tutorial.Java, "4"); System.out.println(map);//w w w . j a v a 2 s. c om Collection<String> values = map.values(); System.out.println("Collection:" + values); }
From source file:Tutorial.java
public static void main(String[] args) { EnumMap<Tutorial, String> map = new EnumMap<Tutorial, String>(Tutorial.class); EnumMap<Tutorial, String> map1 = new EnumMap<Tutorial, String>(map); map.put(Tutorial.CSS, "1"); map.put(Tutorial.Python, "2"); map.put(Tutorial.PHP, "3"); map.put(Tutorial.Java, "4"); System.out.println(map.hashCode()); }
From source file:Tutorial.java
public static void main(String[] args) { EnumMap<Tutorial, String> map = new EnumMap<Tutorial, String>(Tutorial.class); map.put(Tutorial.CSS, "1"); map.put(Tutorial.Python, "2"); map.put(Tutorial.PHP, "3"); map.put(Tutorial.Java, "4"); System.out.println(map);//from w ww. ja v a 2s .c o m // get the value for Tutorial.CSS String value = map.get(Tutorial.CSS); System.out.println("Tutorial.CSS value:" + value); System.out.println("Tutorial.Javascript value:" + map.get(Tutorial.Javascript)); }
From source file:Tutorial.java
public static void main(String[] args) { EnumMap<Tutorial, String> map = new EnumMap<Tutorial, String>(Tutorial.class); map.put(Tutorial.CSS, "1"); map.put(Tutorial.Python, "2"); map.put(Tutorial.PHP, "3"); map.put(Tutorial.Java, "4"); System.out.println(map.hashCode()); map.clear();/*from w w w. j a v a 2s.c o m*/ System.out.println(map.hashCode()); }
From source file:Tutorial.java
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"); System.out.println("Map1: " + map1); System.out.println("Map2: " + map2); map2.putAll(map1);//from w ww. java2 s .co m System.out.println("Map1: " + map1); System.out.println("Map2: " + map2); }
From source file:Tutorial.java
public static void main(String[] args) { EnumMap<Tutorial, String> map = new EnumMap<Tutorial, String>(Tutorial.class); map.put(Tutorial.CSS, "1"); map.put(Tutorial.Python, "2"); map.put(Tutorial.PHP, "3"); map.put(Tutorial.Java, "4"); System.out.println(map);/*from www . j a v a 2 s.c o m*/ String oldValue1 = map.put(Tutorial.Javascript, "5"); String oldValue2 = map.put(Tutorial.CSS, "20"); System.out.println("Updated Map: " + map); System.out.println("First update returns:" + oldValue1); System.out.println("Second update returns:" + oldValue2); }