key相同合并Map

public class Demo11 {

public static void main(String[] args) {
ConcurrentHashMap<Integer, Map<Integer,String>> map = new ConcurrentHashMap<Integer,Map<Integer,String>>();

Map<Integer, String> linkedHashMap = Maps.newLinkedHashMap();
Map<Integer, String> linkedHashMap1 = Maps.newLinkedHashMap();

linkedHashMap.put(1, "a");
linkedHashMap.put(2, "b");
linkedHashMap.put(3, "c");
linkedHashMap.put(4, "d");

linkedHashMap1.put(11, "a1");
linkedHashMap1.put(22, "b2");
linkedHashMap1.put(33, "c3");
linkedHashMap1.put(44, "d4");

linkedHashMap.putAll(linkedHashMap1);

map.put(1, linkedHashMap);





}

}

原文地址:https://www.cnblogs.com/qlwang/p/7724602.html