java8,去重复
作者:互联网
1.对多个字段去重复
ArrayList<SupplierDeliveryCountNum> collect = numlist.stream() .collect(Collectors.collectingAndThen( Collectors.toCollection(() -> new TreeSet<>( Comparator.comparing(o -> o.getDeliveryId() + ";" + o.getNum()))), ArrayList::new));
2. 对全部字段去重复
List<SupplierDeliveryCountNum> distinctIdList = numlist.stream().distinct() .collect(Collectors.toList());
.
标签:Collectors,stream,重复,ArrayList,collect,new,java8,numlist 来源: https://www.cnblogs.com/PinkPink/p/14707362.html