Map<String,Integer> map1= new HashMap<String, Integer>();
map1.put("one",1);
map1.put("two",2);
map1.put("three",3);
Map<String,Integer> map2= new HashMap<String,Integer>();
map2.put("one",1);
map2.put("two",2);
//map1合并到map2中
map1.forEach((key,value) -> map2.merge(key,value,Integer::sum));
System.out.println(JSON.toJSONString(map2));
结果:{"one":2,"three":3,"two":4}