Java Stream of expression

1, how to understand the Stream


Java8 new features

Stream will be appreciated that as the pipe, the pipe is the data of the water, the water pipes can be treated, such as filtration, disinfection, purification, etc. operations. Finally out of the water to drink.

So my concern is to understand the Stream processing data calculations. Contrast java collections framework, a set of framework focuses on how to access the data.

A main stream operation has three parts: the source, intermediate operation, the operation terminates.

Intermediate operation can be 0 or more but not immediately executed only after termination operation is called the intermediate operation will be performed together (execution inert)

It will streamline our operations after the operation has been stream, such as cycling

As a cyclic array printing, as follows, for instead of the original loop, if very simple

int[] intArray = new int[]{2,4,6,1};
Arrays.stream(intArray).forEach(System.out::println);

  

2, Stream Source


 

 stream Source: array collection IO streams

Array:

For example:

int[] intArray = new int[]{2,4,6,1};
Arrays.stream(intArray).forEach(System.out::println);
Stream.of(intArray).forEach(System.out::println);

 

 

Collection Collection

 

I 流

3, intermediate operation


 

 all

4, terminates the operation


all

Guess you like

Origin www.cnblogs.com/yangfei629/p/11427340.html