Concept
Stream
π‘ Streams are single-use β create a new stream for a second pipeline. Milestone: You completed Core APIs (chapters 16β20).
Also known as Streams.
Where it fits
Learn
Existing chapters for this concept.
- Streams & Optional
π‘ Streams are single-use β create a new stream for a second pipeline. Milestone: You completed Core APIs (chapters 16β20).
Open lesson β
See it in code
Existing Java examples.
- core 22 Streams Demo
- Streams are LAZY: intermediate ops (filter/map/sorted) build a pipeline; a terminal op (collect/reduce/forEach/count) triggers execution. - Streams don'tβ¦
Open example β - core23OptionalDemo
- Optional is a container that holds a value or nothing. - Prefer map/filter/flatMap + orElse/orElseThrow over isPresent()/get(). - Use it as a RETURN type;β¦
Open example β
Practice
Existing LeetCode material in JavaForge.
- Find Median from Data Stream
Two heaps: max-heap lower half, min-heap upper half balanced. addNum O(log n), findMedian O(1)
Open practice β - Find Median from Data Stream
Two heaps: max-heap lower half, min-heap upper half balanced. addNum O(log n), findMedian O(1)
Open practice β
Prepare
Existing interview questions.
- parallelStream pool?
Prefer immutability and high-level concurrency utilities over low-level locks.
Open question β - Functional Programming & Streams β Interview Questions (100+)
Keep lambdas pure, stateless, and non-interfering.
Open question β - What is a Stream and how does it differ from a Collection?
A pipeline for processing data; not storage.
Open question β - What does "lazy evaluation" mean for streams?
Work happens only when a terminal op runs, element-by-element.
Open question β - When should you use parallel streams?
Large, CPU-bound, stateless, easily-splittable dataβafter measuring.
Open question β - How do you avoid side effects in streams?
Use pure functions and collectors, not external mutation.
Open question β - What are primitive streams and why use them?
IntStream/LongStream/DoubleStream avoid boxing.
Open question β - Java 9 β Stream takeWhile/dropWhile?
Short-circuit on sorted/predicate prefix; not same as filter.
Open question β
Java versions
- Stream API
Stream API. A stream is a pipeline of intermediate operations and one terminal operation. Intermediate work stays lazy until the terminal operation runs.
Open version note β - Stream additions
Stream additions. takeWhile, dropWhile, and a new iterate overload arrive on Stream. The shared example collects with Collectors.toList(), which alreadyβ¦
Open version note β - Stream.toList()
Stream.toList(). Stream gains toList(), which returns an unmodifiable list. The Java 9β11 example does not call it. It keeps Collectors.toList() so that fileβ¦
Open version note β - Stream Gatherers (Preview)
Stream Gatherers (Preview). A gatherer is a preview intermediate stream operation that can do more than the built-in operations.
Open version note β - Stream Gatherers (Second Preview)
Stream Gatherers (Second Preview). Stream gatherers are previewed a second time.
Open version note β - Stream Gatherers
Stream Gatherers. Gatherers are a permanent intermediate stream operation. Gatherers.windowFixed is one of the built-in gatherers.
Open version note β