赞
踩
List<User> userList = users.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(user -> user.getName()))), ArrayList::new));
根据多个字段去除重复
List<User> userList = users.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(user -> user.getName()+";"+user.getId()))), ArrayList::new));
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。