Streams and Collection Framework in Java
Streams and Collection Framework in Java
The above SQL expression automatically returns the maximum salaried employee's
details, without doing any computation on the developer's end.
Using collections framework in Java, a developer has to use loops and make repeated
checks.
Java 8 introduced the concept of the stream that lets the developer to process data
declaratively.
Cont..
• Sequence of elements − A stream provides a set of elements of specific type in a
sequential manner. A stream gets/computes elements on demand. It never stores the
elements.
• Source − Stream takes Collections, Arrays, or I/O resources as input source.
• Aggregate operations − Stream supports aggregate operations like filter, map, limit,
reduce, find, match, and so on.
• Pipelining − Most of the stream operations return stream itself so that their result can
be pipelined. These operations are called intermediate operations and their function is
to take input, process them, and return output to the target. collect() method is a
terminal operation which is normally present at the end of the pipelining operation to
mark the end of the stream.
Cont..
Cont..
• List<Employee> employees =
Lamda expression..
(a,b) -> a+b
(int a , int b) ->a+b
Summarize
Java Streams and the Collection Framework empower developers to manipulate and
process data with concise, expressive, and functional programming paradigms.
Java Streams and the Collection Framework provide powerful tools for efficient data
manipulation and processing, enabling developers to unleash the full potential of their
applications with elegance and simplicity.