Stream flow of ideas

A, IO stream for reading and writing; Stream stream for processing and collection of data arrays;

1, the traditional collection traversal:

 

 2, the Stream flow filtration mode:

 

Wherein the program chain (return value is the object itself) and, filter using Predicate interface function, it is only an abstract Test () Boolean determined:

 

 

ForEach traversal method () using the data consumption Comsumer function interface, the method body (lambda expression) of the parameter data is processed by the line using the line ::

 

 2, the flow of thought Stream: a production line, only the data source data processing the acquired data is not stored:

 

 Wherein, map step, the mapping may change the set of data types of elements;

Guess you like

Origin www.cnblogs.com/wmqiang/p/11521353.html