- Intermediate: A stream can be followed by 0 or more intermediate operations. The main purpose is to open the stream, make a certain degree of data mapping/filtering, and then return a new stream to be used by the next operation. This type of operation is lazy (lazy), which means that only calls to such a method do not actually begin the traversal of the stream.
- Terminal: A stream can have only one Terminal operation, and when the operation is executed, the stream is used "light" and cannot be manipulated again. So this must be the last operation of the stream. Terminal the execution of the operation, the traversal of the stream is actually started, and a result is generated, or a side effect.
int sum = Widgets.stream (). Filter (W, w.getcolor () = = RED). Maptoint (W-w.getweight ()). sum ();
Stream () gets the Source,filter and maptoint of the current small object for the intermediate operation, for data filtering and conversion, and the last sum () for the terminal operation, which sums up all the small objects that meet the criteria.
Map (Maptoint, FLATMAP, etc.), filter, DISTINCT, sorted, peek, limit, skip, parallel, sequential, unordered
ForEach, foreachordered, ToArray, reduce, collect, Min, Max, Count, AnyMatch, Allmatch, Nonematch, FindFirst, Findany, ite Rator
AnyMatch, Allmatch, Nonematch, FindFirst, Findany, limit
Java Lamda Stream