0% found this document useful (0 votes)
18 views7 pages

Collections 3

The document discusses functional interfaces and lambda expressions introduced in Java 8. It provides examples of common functional interfaces like Runnable, Callable, and Comparable. It also discusses streams and how to create and use streams in Java, including intermediate and terminal stream operations.

Uploaded by

Shahbaz Khan
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)
18 views7 pages

Collections 3

The document discusses functional interfaces and lambda expressions introduced in Java 8. It provides examples of common functional interfaces like Runnable, Callable, and Comparable. It also discusses streams and how to create and use streams in Java, including intermediate and terminal stream operations.

Uploaded by

Shahbaz Khan
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
You are on page 1/ 7

Agent

Interfaces Introduced in Java 8


Functional
Lambda Expressions
streams the cases you
for 991 ofwithout them
I are
fine
Readable
Concise
functional Interfaces
method
interface with
one
only
Runnable M1
task
callable call 1 oriented
to g
Comparable compare
Comparator compare 17

C
Calculator
state
Walker
interface
interface flyable

I walk11 I 411

Interface Segregation Principle


be as
D Interfaces should
SO I possible
light as in
1 method
Ideally only
an interface

How to create a Runnable


and then
create a class to be run in a
parallel thread
make it implement Runnable
class
Create an object of that
the object whenever Ineeded
You pass b
thread
Executor service
Lambda Expressions
of a class that implements
Way to create
an object

a femtional interface
parameter

1
Arrow Femition
Body Lambda Expression

created that implements the


class is
BTS an anonymous
and the code inside the lambda body
interface
in the only method that the interface has
goes
Streams 7 moni

compliance Datasone evening


Teams
hogsing Database
calculates eligibility Messaging Queue
services Kafka Queue
serviced

170
e
7 Team

inter
Integers s stream of 11.3.77
Iream
Integer i 5
for
print i

Data source

FY tomillion
products
name
print product
Alltroducts
histk rodent list productDataSource get

for
Product
pik
p.name
FEE

10 10 1

1 FMB 1041
dbget Product
Stream Product productstream
Product p productstream
for
paint p.name Datasource

ISFFE

have accessed all


Stream afteryou
closes

elements
Can't go back in a
stream

ME

aft
Why
streams in Java

1 More conciseness and Readability


2 Parallel Execution

Entry
Eat
11 177
n

4 Lazy Evaluation
methods in streams
Types of
Terminal methods
1
methods
1 Intermediate

You might also like