📜  java 按属性从列表中删除重复项 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:43.243000             🧑  作者: Mango

代码示例1
import static java.util.Comparator.comparingInt;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toCollection;

...
List unique = employee.stream()
                                .collect(collectingAndThen(toCollection(() -> new TreeSet<>(comparingInt(Employee::getId))),
                                                           ArrayList::new));