不需要通过for 循环对List进行判断,暂存在map,让coding更加simple。
Map<String,List<Item>> invMap =
inst.stream().collect(Collectors.groupingBy(Inm::getncy));
first Group then counting 统计数量
list.stream().collect(Collectors.
groupingBy(item->item.getIhInvNo(),Collectors.counting())).
forEach((key,value)->{
System.out.println(key);
System.out.println(value);
});;
结果:
1
S2400002951
3
S400002952
3