1. 程式人生 > >list通過裡面物件的某個屬性分組或者分組彙總

list通過裡面物件的某個屬性分組或者分組彙總

1,跟據某個屬性分組OfficeId

 Map<String, List<IncomeSumPojo>> collect = list.stream().collect(Collectors.groupingBy(IncomeSumPojo::getOfficeId));

2,根據某個屬性分組OfficeId,彙總某個屬性Money

Map<String, Double> collect = list.stream().collect(Collectors.groupingBy(IncomeSumPojo::getOfficeId,Collectors.summingDouble(IncomeSumPojo::getMoney)));