0% found this document useful (0 votes)
5 views4 pages

Java 8 Stream API Basics Explained

The Stream API, introduced in Java 8, allows for processing collections of objects using a sequence of methods that can be pipelined for desired results. It supports various operations such as filtering, mapping, and sorting, enabling efficient data manipulation. Stream objects can only be used once, and they include both intermediate and terminal operations for handling data streams.

Uploaded by

desmondavi0013
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Java 8 Stream API Basics Explained

The Stream API, introduced in Java 8, allows for processing collections of objects using a sequence of methods that can be pipelined for desired results. It supports various operations such as filtering, mapping, and sorting, enabling efficient data manipulation. Stream objects can only be used once, and they include both intermediate and terminal operations for handling data streams.

Uploaded by

desmondavi0013
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Stream API

Stream API is introduced in Java 8


It used toprocess collections
is
of object
It objects that supports
is a
sequence of
various methods that can be pipelined to produce
the desired result
List String empName new ArrayList string
for emp
Employee emp
frames add
employees
ttrame
[Link]
System out printer empNames

11 With Stream
Stream Employee employeesStream employeesstream

11Stream Pipeline
List String allemployeeNames employeesStream map emp empgetramel
System out printer allemployee frames to list

11filter Intermediate
11 EmployeeNames Age 25
operation
ˢᵗʰ
Fty [Link]
fp
empgtage 25 [Link]
map emp
HolistI
Intermediate
d
operations
operation
We can use a stream object only once
employees2 stream
map ems emp getcity
Integrate fr printtnT1IIs
[Link]
Terminal operation
limit 3

3
Skip
I Match returns boolean
any
I
verify any emp 218
boolean isUnder stream
Age employees
Match
any emp emp getAge
18

11 all Match returns boolean


1 Check joined 2010 or not
every employee after
Any 1
find
II value out of all values
get one
from
11 sorted Comparator Arg
11
Define sorting based on
employee Id's
1 Sort Employee objects
employees stream
sorted et e2
return et get Idl e2 Id
3 toList get
11 minimum salary employee details
employees stream
[Link]
returns optional
object t.glh5

You might also like