Stream Introduction

原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/12811475.html

Definition

A short definition is a sequence of elements from a source that supports data processing operations.

intermediate vs. terminal operations

Intermediate operations

Intermediate operations such as filter or sorted return another stream as the return type. This allows the operations to be connected to form a query. What’s important is that intermediate operations don’t perform any processing until a terminal operation is invoked on the stream pipeline—they’re lazy. This is because intermediate operations can usually be merged and processed into a single pass by the terminal operation.

Terminal operations

Terminal operations produce a result from a stream pipeline. A result is any nonstream value such as a List, an Integer, or even void.

Reference

Manning.Java.8.in.Action.Lambdas.Streams.and.functional-style.programming

原文地址:https://www.cnblogs.com/agilestyle/p/12811475.html