Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #java #remove #duplicates #list #property
ADD COMMENT
Topic
Name
3+5 =