欢迎来到我的博客

stream流按某类型分组后操作

比如查询出了所有学生的各科成绩列表,再按学生分组求和

Map<Integer, Double> collect = testList.stream().collect(Collectors.groupingBy(UserEntity::getUserId, Collectors.summingDouble(f -> Double.parseDouble(f.getScore()))));

Collectors收集器


posted @ 2023-02-24 09:08  fchhk  阅读(41)  评论(0)    收藏  举报