Stream in java is major concept of Java 8. In java stream operations, we have two parts of operation one is intermediate operations and terminal operations. In this post we will discuss about the java stream collect, java stream foreach, stream sorted, java stream filter, java stream distinct, java stream reduce, java stream collect, stream reduce.
Java stream operations
1. By use of intermediate operation, you can perform the various operations in a row.
Because intermediate operation produces a stream and sends next to operation.
2. The intermediate operations could not able to produce the final result.
3. Intermediate operation is used by the terminal operation as an input.
1. The terminal operations take Stream as input and produce the result.
2. After completion of the Terminal operation, you can’t use the Stream.
3. Terminal operation is eager in nature. The terminal operation processes all the elements of the stream before return the result.
We will discuss some Terminal operations: