Fundamentals

Default Methods

Collections

Idioms and Techniques

Design Rationale

Advanced Questions

How can I get distinct() to compare some derived value instead of the stream elements themselves?

The distinct() stream operation compares the stream’s elements directly to each other using Object.equals(), but there’s no obvious way to have it compute uniqueness based on some value derived from each stream element.

Here’s a snippet of code do this. This is used in a filter() operation, and it takes a key extractor function to […]