Map<String,String> map1= new HashMap<String, String>(){{
put("no1","123"); put("no2","5434"); put("no5","234");}};
Map<String,String> map2 = new HashMap<String, String>(){{
put("no1","523"); put("no2","234"); put("no3","234");}};
Multimap<String, String> totalMap = ArrayListMultimap.create();
totalMap.putAll()
仅支持Multimap。如何将所有map1和map2放入多图?
答案 0 :(得分:6)
使用Multimaps.forMap(Map<K,V>)
获取地图的Multimap
视图,然后将其添加到totalMap
,例如:
totalMap.putAll(Multimaps.forMap(map1));