1.计数返回Integer类型
Map<Integer,Integer> ret = rackAllocationList.stream().collect(Collectors.groupingBy(RackAllocationPO::getOrderId,
Collectors.collectingAndThen(
Collectors.toList(),
List::size)
));
2.计数返回Long类型
Map<Integer,Long> ret =
rackAllocationList.stream().collect(Collectors.groupingBy(
RackAllocationPO::getOrderId,
Collectors.counting()));

6112

被折叠的 条评论
为什么被折叠?



