Java Reference
In-Depth Information
17
Java SE 8 Lambdas and
Streams
Oh, could I flow like thee,
and make thy stream
My great example,
as it is my theme!
—Sir John Denham
Objectives
In this chapter you'll:
Learn what functional
programming is and how it
complements object-oriented
programming.
■
Use functional programming
to simplify programming
tasks you've performed with
other techniques.
■
Write lambda expressions
that implement functional
interfaces.
■
Learn what streams are and
how stream pipelines are
formed from stream sources,
intermediate operations and
terminal operations.
■
Perform operations on
IntStream
s, including
forEach
,
count
,
min
,
max
,
sum
,
average
,
reduce
,
filter
and
sorted
.
■
Perform operations on
Stream
s, including
filter
,
map
,
sorted
,
collect
,
forEach
,
findFirst
,
distinct
,
mapToDouble
and
reduce
.
■
Create streams representing
ranges of
int
values and
random
int
values.
■