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());

  

 

 

 

 

 

.

posted @ 2021-04-27 08:40  岁月尔尔  阅读(433)  评论(0编辑  收藏  举报