In Java 8 how can I filter a collection using the Stream API by checking the distinctness of a property of each object?
Stream
For example I have a list of
Another library that supports this is jOOλ, and its Seq.distinct(Function) method:
Seq.seq(persons).distinct(Person::getName).toList();
Under the hood, it does practically the same thing as the accepted answer, though.