Java Streams are pipelines that pull objects from a source and push them downstream — they store zero objects by default. However, some operations like distinct() and sorted() maintain internal mutable state by storing elements (in a set or buffer). Regular operations like map, filter, and flatMap store nothing. This design makes the Stream API memory-efficient, capable of processing datasets far larger than available heap memory.

1m watch time

Sort: