I\'m trying to find separate the duplicates and non-duplicates in a List
by adding them to a Set
and List
while using Stream.fil
There is a more elegant way to use the filter
with Predicate negate()
method instead of using logical operator !
List extras = strings
.stream()
.filter(((Predicate) distinct::add).negate())
.peek(System.out::println)
.collect(Collectors.toList());
peek
is a function used for pipeline debugging only.