编程语言
首页 > 编程语言> > 收集Java8 Lambda map-reduce代码

收集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())));

 

标签:map,addAll,Map,entrySet,reduce,entries,put,idCountMap2,Java8
来源: https://www.cnblogs.com/tekikesyo/p/15838952.html