Online Java Compiler By
JavaTpoint.com
import java.util.*; public class EnumMapPutAllExample1 { // create an enum public enum Days { Monday,Tuesday, Wednesday, Thursday }; public static void main(String[] args) { EnumMap
map1 = new EnumMap
(Days.class); EnumMap
map2 = new EnumMap
(Days.class); map1.put(Days.Monday, "1"); map1.put(Days.Tuesday, "2"); map1.put(Days.Wednesday, "3"); // print map1 and map2 System.out.println("Map1: "+map1); System.out.println("Map2: "+map2); // copy all the mappings from map1 to map2 map2.putAll(map1); //print map1 and map2 again System.out.println("Map1: "+map1); System.out.println("Map2: "+map2); } }
Output