Java 8 Streams
Stream In Java
Introduced in Java 8, Stream API is used to process collections of objects. A stream in Java is a sequence of objects that supports various methods which can be pipelined to produce the desired result.
Use of Stream in Java
- Stream API is a way to express and process collections of objects.
- Enable us to perform operations like filtering, mapping,reducing and sorting.
Java Stream Features
The features of Java stream are mentioned below:
- A stream is not a data structure instead it takes input from the Collections, Arrays or I/O channels.
- Streams don’t change the original data structure, they only provide the result as per the pipelined methods.
- Each intermediate operation is lazily executed and returns a stream as a result, hence various intermediate operations can be pipelined. Terminal operations mark the end of the stream and return the result.
Operations on Streams:
📄️ Creating Streams
Create Java Stream
🗃️ Operations on Streams
2 items
🗃️ Collectors
6 items
📄️ Examples
- Java-8 Streams Creating Streams