stateful operation

A stream operation such as sorted or distinct that must remember elements it has seen before it can pass results on.

In more detail

sorted has to hold enough elements to order them and distinct remembers every value it has seen. On large sources that costs memory, so drop them when the input is already ordered or unique.

Example

.distinct().sorted()

Related terms

Taught in

References

Certification courses