Java8 four core functional interfaces
Customer <T>: Consumer Interface void accept (T t);
Supplier <T>: Interface for TG et hexyl ();
Function <T, R>: Function Interface R apply (T t);
predicate <T>: Interface asserted (decision) boolean test (T t);
First, the reference method: If the content lambda body there are ways been achieved, we can "reference method" (understood as the method is the same as another form of lambda expressions)
There are three main {
Object: instance method name
Categories: static method name
Class: instance method names
}
Note:
1, method call parameter list lambda body and the parameter list and return the type of abstract methods and functions return a consistent interface type
2, when the first parameter lambda parameter list examples of methods is the caller and the second parameter is a parameter example of the method can be used when ClassName: method
Second, the reference constructor
To call the constructor parameter list and the function parameter list is inconsistent
ClassName :: new format
Cited three arrays Type :: new
StreamAPI
What stream (stream) is
Is a data channel, an operating element sequence data generated by the source.
Talking about the collection of data, it is to calculate the stresses stream
Note: Stream does not own storage element, stream does not change the source object Instead they will return the results of a new holding of stream flow, stream operations are delayed execution, meaning they will need to wait until the results of the implementation of
stream flow Middleware
Multi-middleware operation can be connected together to form a pipeline, unless the termination is triggered on the assembly line operation, or operation is not performed any intermediate process: when the operation is terminated once all processing is called "inert Job"
Slice and screening
method:
filter (Predicate p) receiving lambda, certain elements from the stream discharged
DISTINCT () brush option, stream generated by the hashcode () and equals () removal of certain repetitive elements
limit (long maxSize) cut off the flow, so that the element does not exceed a given number of
skip (long n) skipped element, a return flow throw the first few elements, if less flow returns empty element
Mapping
method:
map (function f): receiving a function as an argument, the function will be applied to each element mapped to forward a new element
mapToDouble (ToDoubleFunction f): j accepts as a parameter a function, the function is applied to each element, generating a new DoubleStream
mapToInt (ToIntFunction f): receiving a function as an argument, the function will be applied to each element of the above, to produce a new IntStream
maoToLong (ToLonFunction f): a function accepts as a parameter, the function will be applied to each element, to produce a new LongStream
flatmap (Function f): a function accepts as a parameter, the value of each stream are replaced by another stream, and all the streams are connected into one stream
Sequence
method:
sorted (): generates a new stream, which is sorted according to the natural order
sorted (comparator cop): generates a new stream, which is sorted in order of the comparison
Find matches
alllMath (Predictate p): check that all the elements match
anyMatch (Predictate p): Check whether the match at least one element
noneMatch (predictate p): Check if there is no match for all elements
findFirst (): returns the first element
findAny (): returns the arbitrary element
Reduction
reduce (T identity, BinaryOpeartor) repeatedly stream elements combine to give a value
collect
collect - receiving the stream into a collector for other forms of interface, for aggregation of stream do.
stream termination of operation
The terminal will generate flow from the pipeline, the result may be any value not flow
Parallel and serial flow stream
Fork / Join framework (work stealing mode)