Lambda, Stream API

Lambda

Runnable r = () -> System.out.println(“Run, Lambda!”);

Use the built-in interfaces included in the java.util.function package such as Predicate, Consumer, Function, and Supplier
Develop code that uses primitive versions of functional interfaces
Develop code that uses binary versions of functional interfaces
Develop code that uses the UnaryOperator interface

java.util.stream

BaseStream<T,S extends BaseStream<T,S>>
Collector<T,A,R>
Stream
Stream.Builder
Collectors
StreamSupport

How to Create Stream?

The class StreamSupport has a number of low-level methods for creating a stream, all using some form of a Spliterator (Spliterators.spliteratorUnknownSize(java.util.Iterator, int). A late-binding Spliterator binds to the source of elements at the point of first traversal, first split, or first query for estimated size, rather than at the time the Spliterator is created. A Spliterator that is not late-binding binds to the source of elements at the point of construction or first invocation of any method.)

Create stream from iterator (spliterator)

Collection via the stream() and parallelStream() methods

What is intermediate operations?

filter
skip
distinct
map
peek
limit
sorted
mapToInt, mapToDouble, mapToLong
flatMap, flatMapToInt, flatMapToDouble, flatMapToLong
parallel
sequential

What is terminal operations?

findFirst
findAny
collect
count
anyMatch
noneMatch
allMatch
min
max
forEach
forEachOrdered
toArray
reduce
sum
average
mapToObj
isParallel

Leave a comment

Your email address will not be published. Required fields are marked *