Stream was introduced in Java 8 and it is only used to process a set of data and not to sort the elements. It does not modify the actual collection, they only provide results according to the pipeline method.
The Stream API supports multiple operations, which are divided into two parts:
serial number | Keywords | Intermediate Operations | Terminal Operations |
---|---|---|---|
Basic Operations | These operations are used to pipe other methods and convert to other streams | Terminal operations in Java are the last step methods applied to a stream . | |
Return Type | They just return another flow. | They return the final result. | |
Method | sorted(Comparator | peek(Consumer ##forEach |
count toArray | ##4.
Use Case | These operations should be used to transform a stream into another stream | They can be used to generate results. |
The above is the detailed content of The difference between intermediate operations and terminal operations in Java 8. For more information, please follow other related articles on the PHP Chinese website!