SlideShare a Scribd company logo
Lambda Functions
Outline
 Behavior parameterization ?
 Lambda in nutshell
 Function Interface
 Type Checking
 Local variables and Closure
 Method reference
Behavior parameterization
 Demo
Lambda in nutshell
 Anonymous
 Passed around
 Concise
Syntax
 No Arguments
 One Argument
 Multiple Arguments
 With Explicit argument types
 Multiple Statements
Function Interface
 It’s an interface with exactly one abstract method.
 Example: Runnable, Callable, Comparator.
 A functional interface can have multiple default methods
 Functional descriptor
Common Functional Interfaces in JDK8
Type Checking
new OptSumOfNumbers().findSum(i -> true, numbers);
findSum(Predicate<Integer> predicate, List<Integer> numbers)
What is the functional descriptor for predicate ?
Functional descriptor Integer -> boolean matches lambda
expression.
Target Type:
Predicate<Integer>
Integer -> boolean
Restrictions on local variables & Closure
 Demo
Method reference
Lambda Method Reference Equivalent
(TripModel trip) -> trip.getTripId() TripModel::getTripId
(String s) -> System.out.println(s) System.out::println
(str, i) -> str.substring(i) String::substring
() -> Thread.currentThread().dumpStack() Thread.currentThread()::dumpStack
Method reference
 A method reference to a static method.
 A method reference to an instance method of an object of a particular type.
 A method reference to an instance method of an existing object.
 A method reference to a constructor.

More Related Content

PPTX
Fun with lambda expressions
PPTX
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
PPT
Getting started with c++
PDF
Compiler Construction | Lecture 7 | Type Checking
PPTX
Functions in python slide share
PPTX
Introduction To Programming with Python-1
PDF
C intro
Fun with lambda expressions
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Getting started with c++
Compiler Construction | Lecture 7 | Type Checking
Functions in python slide share
Introduction To Programming with Python-1
C intro

What's hot (19)

PDF
Unit iii
PDF
tutorials-c-sharp_understanding-generic-anonymous-methods-and-lambda-expressi...
PDF
C++ Object oriented concepts & programming
PPTX
Introduction to Python Basics
PDF
Java 8 Lambda Expressions & Streams
PPT
20130329 introduction to linq
PPT
Python Built-in Functions and Use cases
PPTX
Lexical analysis-using-lex
PDF
Fundamentals of Computing and C Programming - Part 1
PDF
Fundamentals of Computing and C Programming - Part 2
PDF
Lambda Expressions in Java
PDF
Programming in C Session 1
PDF
Control structures functions and modules in python programming
PPTX
Functions in Python
PDF
Semantic Analysis of a C Program
PPTX
Introduction To Programming with Python Lecture 2
PPTX
Java 8 presentation
PPT
Parsing
PDF
Unit iii
tutorials-c-sharp_understanding-generic-anonymous-methods-and-lambda-expressi...
C++ Object oriented concepts & programming
Introduction to Python Basics
Java 8 Lambda Expressions & Streams
20130329 introduction to linq
Python Built-in Functions and Use cases
Lexical analysis-using-lex
Fundamentals of Computing and C Programming - Part 1
Fundamentals of Computing and C Programming - Part 2
Lambda Expressions in Java
Programming in C Session 1
Control structures functions and modules in python programming
Functions in Python
Semantic Analysis of a C Program
Introduction To Programming with Python Lecture 2
Java 8 presentation
Parsing
Ad

Similar to JDK8 Lambda expressions demo (20)

PDF
Lambda Expression For anyone that needs Java Lambda notes
PPTX
Project Lambda: Evolution of Java
PPTX
Lambdas, Collections Framework, Stream API
PPTX
PDF
Lambdas in Java 8
PPTX
Java 8 lambda
PPTX
JDK8 Lambdas and Streams: Changing The Way You Think When Developing Java
PPTX
Week-1..................................
PPTX
Introduction to functional programming with java 8
PDF
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
PPTX
Simple Lambdas in java in oca 8.0 on feb
PDF
Hanoi JUG: Java 8 & lambdas
PDF
PDF
Productive Programming in Java 8 - with Lambdas and Streams
PPTX
Lambdas : Beyond The Basics
PDF
Unit-3.pptx.pdf java api knowledge apiii
PPTX
Functional Interfaces and Method References.pptx
PDF
Java 8 features
PPTX
Java 8 features
PDF
Java 8 Lambda Built-in Functional Interfaces
Lambda Expression For anyone that needs Java Lambda notes
Project Lambda: Evolution of Java
Lambdas, Collections Framework, Stream API
Lambdas in Java 8
Java 8 lambda
JDK8 Lambdas and Streams: Changing The Way You Think When Developing Java
Week-1..................................
Introduction to functional programming with java 8
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Simple Lambdas in java in oca 8.0 on feb
Hanoi JUG: Java 8 & lambdas
Productive Programming in Java 8 - with Lambdas and Streams
Lambdas : Beyond The Basics
Unit-3.pptx.pdf java api knowledge apiii
Functional Interfaces and Method References.pptx
Java 8 features
Java 8 features
Java 8 Lambda Built-in Functional Interfaces
Ad

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Machine Learning_overview_presentation.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Electronic commerce courselecture one. Pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
A Presentation on Artificial Intelligence
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
Teaching material agriculture food technology
PPTX
Spectroscopy.pptx food analysis technology
Encapsulation theory and applications.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Machine Learning_overview_presentation.pptx
Programs and apps: productivity, graphics, security and other tools
Electronic commerce courselecture one. Pdf
Network Security Unit 5.pdf for BCA BBA.
MIND Revenue Release Quarter 2 2025 Press Release
Building Integrated photovoltaic BIPV_UPV.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
cuic standard and advanced reporting.pdf
A comparative analysis of optical character recognition models for extracting...
Machine learning based COVID-19 study performance prediction
Group 1 Presentation -Planning and Decision Making .pptx
Spectral efficient network and resource selection model in 5G networks
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
A Presentation on Artificial Intelligence
20250228 LYD VKU AI Blended-Learning.pptx
Teaching material agriculture food technology
Spectroscopy.pptx food analysis technology

JDK8 Lambda expressions demo

Editor's Notes

  • #7: Signature of the abstract method is very important since we use it describe the signature of Lambda expression. We can this abstract method as function descriptor.