Java.util.EnumMap.putAll() 方法 Java.util.Formatter.format() 方法 Java.util.Formatter.format() 方法 Java.util.EnumMap.putAll() 方法 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"); // print the maps System.out.println("Map1: " + map1); System.out.println("Map2: " + map2); // put all mapping from map1 to map 2 map2.putAll(map1); // print the maps System.out.println("Map1: " + map1); System.out.println("Map2: " + map2); } } Java.util.Formatter.format() 方法 Java.util.Formatter.format() 方法