- provides sequential or parallel aggregation functions over source data (array, collection, I/O channel, ...)
- streams have
close()
- in most cases this method doesn't have to be called explicit because streams implement
AutoClosable
interface - in fact, close the stream is only needed of it's a I/O channel as source
- in most cases this method doesn't have to be called explicit because streams implement
- as well as common
Stream
for any object are provided three specific streams for primitive types:IntStream
LongStream
DoubleStream
Stream#empty()
,Stream#of()
,Stream#concat()
Stream#generate()
,Stream#iterate()
- provides infinite streams
- should be terminated by throwing exception
or clever usage e.g.
anyMatch()
operation
Stream.Builder<T> add(T t)
void accept(T t)
Stream<T> build()
- set of operations that Stream will do
- can contain 0..n intermediate operations and exactly one terminal operation
- source data can be array, collection, I/O channel, ...
- Stream will do only if terminal operation was called
- input argument of operations is always implementation of functional interface
reduce()
,min()
,max()
,count()
,forEach()
,forEachOrdered()
,collect()
,toArray()
,iterator()
,spliterator()
findFirst()
,findAny()
,allMatch()
,anyMatch()
,noneMatch()
peek()
,map()
,flatMap()
,filter()
,parallel()
,sequential()
,onClose()
,unordered()
distinct()
,sorted()
limit()
,skip()
...TBD...