收集Java8 Lambda map-reduce代码
一段代码-累计
Map<String, Long> idCountMap2 = new HashMap<>(); idCountMap2.put("1", 10L); idCountMap2.put("2", 12L); entries.addAll(idCountMap.entrySet()); entries.addAll(idCountMap2.entrySet()); Map<String, Long> total = entries.stream() .collect(Collectors.groupingBy(m -> m.getKey(), Collectors.summingLong(m -> m.getValue())));