Answers for "java remove duplicates from list by property"

0

java remove duplicates from list by property

import static java.util.Comparator.comparingInt;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toCollection;

...
List<Employee> unique = employee.stream()
                                .collect(collectingAndThen(toCollection(() -> new TreeSet<>(comparingInt(Employee::getId))),
                                                           ArrayList::new));
Posted by: Guest on December-07-2021

Code answers related to "java remove duplicates from list by property"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language