Java-8 :: Stream API

 Streams are an update to the Java API that lets you manipulate collections of data in a declarative way (you express a query rather  than code an ad hoc implementation for it). For now you can think of them as fancy iterators over a collection of data. 
In  addition, streams can be processed in parallel transparently, without you having to write any multithreaded code!
To summarize, the Streams API in Java 8 lets you write code that’s
Declarative— More concise and readable
Composable— Greater flexibility
Parallelizable— Better performance

We’ll look at many patterns such as filtering, slicing, finding, matching, mapping, and reducing

Working with streams
To summarize, working with streams in general involves three items:
A data source (such as a collection) to perform a query on
A chain of intermediate operations that form a stream pipeline
A terminal operation that executes the stream pipeline and produces a result

SUMMARY
Here are some key concepts to take away from this chapter:
A stream is a sequence of elements from a source that supports data processing operations.
Streams make use of internal iteration: the iteration is abstracted away through operations such as filter, map, and sorted.
There are two types of stream operations: intermediate and terminal operations.
Intermediate operations such as filter and map return a stream and can be chained together. They’re used to set up a pipeline of operations but don’t produce any result.
Terminal operations such as forEach and count return a nonstream value and process a stream pipeline to return a result.
The elements of a stream are computed on demand.

Comments

Popular posts from this blog

PUTTY - The server's host key is not cached in the registry cache

OIM-12c Installation - FMW - SOA - IDM

SAML & OAuth 2.0