Java FAQ: Top Questions
24. What is the Java Stream API?
The Java Stream API , introduced in Java 8, enables functional-style operations on collections, processing data in a declarative way. Streams support operations like filtering, mapping, and reducing.
-
Stream Creation:
From collections via
stream()orparallelStream(). -
Operations:
Intermediate (e.g.,
filter,map) and terminal (e.g.,collect,reduce). - Lazy Evaluation: Intermediate operations are executed only when a terminal operation is invoked.
- Parallel Processing: Supports parallel streams for performance.
