SlideShare uma empresa Scribd logo
1 de 30
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
01
02
03
05
06
07
Java Lambda Expressions
Functional Interface
Lambda Parameters
Lambda as an Object
Lambda Value Capture
Method References as
Lambdas
Topics For Today’s Discussion
Java Lambda
Expressions
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
It provides the implementation of a functional interface & simplifies the software development
It provides a clear and concise way to represent a method interface via an expression
Java Lambda Expressions
It is an anonymous function that doesn’t have a name and doesn’t belong to any class
Java lambda expressions are Java's first step into functional programming
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
parameter -> expression body->
Java Lambda Expressions
Syntax
Characteristics
-> Optional Type Declarations
-> Optional Parenthesis Around Parameters
-> Optional Curly Braces
-> Optional return keyword
Arrow Operator is introduced in Java through lambda
expressions that divides it into two parts i.e Parameters & Body
Functional
Interface
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Functional Interface
Functional Interface is
an interface that
contains exactly one
abstract method
It can have any
number of default or
static methods along
with object class
methods
Java provides
predefined functional
interfaces to deal with
functional
programming
Runnable,
ActionListener,
Comparable are some
of the examples of
functional interfaces
01 02 03 04
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Functional Interface
@FunctionalInterface
interface displayable{
void display(String msg);
}
public class Test implements displayable{
public void display(String msg){
System.out.println(msg);
}
public static void main(String[] args) {
Test dis = new Test();
dis.display("Welcome to Lambda Tutorial by Edureka!");
}
}
Lambda
parameters
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Lambda Parameters
Lambda Expressions can take parameters just like methods
1 2 3
Zero Parameters One Parameter Multiple Parameters
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Lambda Parameters
1
2
3
Zero Parameters
One Parameter
Multiple Parameters
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Lambda Parameters
1
2
3
Zero Parameters
One Parameter
Multiple Parameters
() -> System.out.println("Zero parameter lambda");
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Lambda Parameters
1
2
3
Zero Parameters
One Parameter
Multiple Parameters
() -> System.out.println("Zero parameter lambda");
(param) -> System.out.println("One parameter: " + param);
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Lambda Parameters
1
2
3
Zero Parameters
One Parameter
Multiple Parameters
() -> System.out.println("Zero parameter lambda");
(param) -> System.out.println("One parameter: " + param);
(p1, p2) -> System.out.println("Multiple parameters: " +
p1 + ", " + p2);
Lambda As An
object
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Lambda as an Object
A Java lambda expression is essentially an object that can be assigned to a variable and passed around
public interface LambdaComparator {
public boolean compare(int a1, int a2);
}
LambdaComparator myComparator = (a1, a2) -> return a1 > a2;
boolean result = myComparator.compare(2, 5);
Interface
Implementing
class
Lambda Variable
Capture
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Variable Capture
Java lambda expression can access variables that are declared outside the lambda function body under
certain circumstances
1 2 3
Local Variable Instance Variables Static Variables
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Lambda Parameters
1
2
3
Local Variable
Instance Variables
Static Variables
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Lambda Parameters
1
2
3
Local Variable
String myStr = "Welcome to Edureka!";
MyLambda dis = (chars) -> {
return myStr + ":" + new String(chars);
};
Instance Variables
Static Variables
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Lambda Parameters
1
2
3
Local Variable
Instance Variables
Static Variables
public class LambdaStaticConsumerDemo {
private String str = "Lambda Consumer";
public void attach(LambdaStaticProducerDemo eventProd){
eventProd.listen(e -> {
System.out.println(this.str);
});
}
}
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Lambda Parameters
1
2
3
Local Variable
Instance Variables
Static Variables
public class LambdaStaticConsumerDemo {
private static String myStaticVar = "Edureka!";
public void attach(LambdaStaticProducerDemo eventProd){
eventProd.listen(e -> {
System.out.println(myStaticVar);
});
}
}
Method references
As lambdas
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Method References
Java lambda expression can access variables that are declared outside the lambda function body under
certain circumstances
Static Method
Reference
1 2 3 4
Parameter Method
Reference
Instance Method
Reference
Constructor Method
Reference
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Method References
Static Method
Reference
1
2
3
4
Parameter Method
Reference
Instance Method
Reference
Constructor Method
Reference
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Class
Lambda Expression
Interface
Method References - Static
Static Method
Reference1
2
3
4
Parameter Method
Reference
Instance Method
Reference
Constructor Method
Reference
public interface Display {
public int show(String s1, String s2);
}
public class Test{
public static int doShow(String s1, String s2){
return s1.lastIndexOf(s2);
}
}
Display disp = Test::doShow;
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Method References - Parameter
Static Method
Reference
1
2
3
4
Parameter Method
Reference
Instance Method
Reference
Constructor Method
Reference
Interface
public interface Display {
public int show(String s1, String s2);
}
Lambda Expression
Display disp = String::indexOf;
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Method References - Instance
Static Method
Reference
1
2
3
4
Parameter Method
Reference
Instance Method
Reference
Constructor Method
Reference
Interface
public interface Deserializer {
public int deserialize(String v1);
}
Class
Lambda Expression
public class StringConverter {
public int convertToInt(String v1){
return Integer.valueOf(v1);
}
}
StringConverter strConv = new StringConverter();
Deserializer deserializer = strConv::convertToInt;
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Method References - Constructor
Static Method
Reference
1
2
3
4
Parameter Method
Reference
Instance Method
Reference
Constructor Method
Reference
Interface
public interface Factory {
public String create(char[] val);
}
Lambda Expression
Factory fact = String::new;
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Training | Edureka

Mais conteúdo relacionado

Mais procurados

Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New FeaturesAli BAKAN
 
Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaMOHIT AGARWAL
 
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
Java Programming | Java Tutorial For Beginners | Java Training | EdurekaJava Programming | Java Tutorial For Beginners | Java Training | Edureka
Java Programming | Java Tutorial For Beginners | Java Training | EdurekaEdureka!
 
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...Edureka!
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in javaPratik Soares
 
Java Basics
Java BasicsJava Basics
Java BasicsSunil OS
 
Access modifiers
Access modifiersAccess modifiers
Access modifiersJadavsejal
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with MavenSid Anand
 
What Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
What Is Java | Java Tutorial | Java Programming | Learn Java | EdurekaWhat Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
What Is Java | Java Tutorial | Java Programming | Learn Java | EdurekaEdureka!
 

Mais procurados (20)

Spring Boot
Spring BootSpring Boot
Spring Boot
 
Abstract class
Abstract classAbstract class
Abstract class
 
Java
JavaJava
Java
 
Inner classes in java
Inner classes in javaInner classes in java
Inner classes in java
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New Features
 
Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core Java
 
Java basic
Java basicJava basic
Java basic
 
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
Java Programming | Java Tutorial For Beginners | Java Training | EdurekaJava Programming | Java Tutorial For Beginners | Java Training | Edureka
Java Programming | Java Tutorial For Beginners | Java Training | Edureka
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
 
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Java 8 Lambda and Streams
Java 8 Lambda and StreamsJava 8 Lambda and Streams
Java 8 Lambda and Streams
 
Access modifiers
Access modifiersAccess modifiers
Access modifiers
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
 
What Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
What Is Java | Java Tutorial | Java Programming | Learn Java | EdurekaWhat Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
What Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
 

Semelhante a Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Training | Edureka

Java moderno java para Jedis episodio I
Java moderno  java para  Jedis  episodio IJava moderno  java para  Jedis  episodio I
Java moderno java para Jedis episodio IRoan Brasil Monteiro
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Java 8 lambdas expressions
Java 8 lambdas expressionsJava 8 lambdas expressions
Java 8 lambdas expressionsLars Lemos
 
What's new in java 8
What's new in java 8What's new in java 8
What's new in java 8Dian Aditya
 
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 OverviewEclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 OverviewEclipse Day India
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsEmiel Paasschens
 
Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3Simon Ritter
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentationVan Huong
 
Introduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applicationsIntroduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applicationsFulvio Corno
 
Functional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhFunctional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhHarmeet Singh(Taara)
 
Functional Programming With Lambdas and Streams in JDK8
 Functional Programming With Lambdas and Streams in JDK8 Functional Programming With Lambdas and Streams in JDK8
Functional Programming With Lambdas and Streams in JDK8IndicThreads
 
imperative programming language, java, android
imperative programming language, java, androidimperative programming language, java, android
imperative programming language, java, androidi i
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 itiAhmed mar3y
 
使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)
使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)
使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)Amazon Web Services
 

Semelhante a Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Training | Edureka (20)

Java moderno java para Jedis episodio I
Java moderno  java para  Jedis  episodio IJava moderno  java para  Jedis  episodio I
Java moderno java para Jedis episodio I
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java 8 lambdas expressions
Java 8 lambdas expressionsJava 8 lambdas expressions
Java 8 lambdas expressions
 
Java8 features
Java8 featuresJava8 features
Java8 features
 
What's new in java 8
What's new in java 8What's new in java 8
What's new in java 8
 
Cs30 New
Cs30 NewCs30 New
Cs30 New
 
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 OverviewEclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 Overview
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
 
Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 
Introduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applicationsIntroduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applications
 
Functional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhFunctional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singh
 
Functional Programming With Lambdas and Streams in JDK8
 Functional Programming With Lambdas and Streams in JDK8 Functional Programming With Lambdas and Streams in JDK8
Functional Programming With Lambdas and Streams in JDK8
 
Java RMI
Java RMIJava RMI
Java RMI
 
imperative programming language, java, android
imperative programming language, java, androidimperative programming language, java, android
imperative programming language, java, android
 
Java 8
Java 8Java 8
Java 8
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 iti
 
使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)
使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)
使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)
 

Mais de Edureka!

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaEdureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaEdureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaEdureka!
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaEdureka!
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaEdureka!
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaEdureka!
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaEdureka!
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaEdureka!
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaEdureka!
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaEdureka!
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | EdurekaEdureka!
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEdureka!
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEdureka!
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaEdureka!
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaEdureka!
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaEdureka!
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaEdureka!
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaEdureka!
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | EdurekaEdureka!
 

Mais de Edureka! (20)

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 

Último (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Training | Edureka

  • 1.
  • 2. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training 01 02 03 05 06 07 Java Lambda Expressions Functional Interface Lambda Parameters Lambda as an Object Lambda Value Capture Method References as Lambdas Topics For Today’s Discussion
  • 4. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training It provides the implementation of a functional interface & simplifies the software development It provides a clear and concise way to represent a method interface via an expression Java Lambda Expressions It is an anonymous function that doesn’t have a name and doesn’t belong to any class Java lambda expressions are Java's first step into functional programming
  • 5. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training parameter -> expression body-> Java Lambda Expressions Syntax Characteristics -> Optional Type Declarations -> Optional Parenthesis Around Parameters -> Optional Curly Braces -> Optional return keyword Arrow Operator is introduced in Java through lambda expressions that divides it into two parts i.e Parameters & Body
  • 7. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Functional Interface Functional Interface is an interface that contains exactly one abstract method It can have any number of default or static methods along with object class methods Java provides predefined functional interfaces to deal with functional programming Runnable, ActionListener, Comparable are some of the examples of functional interfaces 01 02 03 04
  • 8. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Functional Interface @FunctionalInterface interface displayable{ void display(String msg); } public class Test implements displayable{ public void display(String msg){ System.out.println(msg); } public static void main(String[] args) { Test dis = new Test(); dis.display("Welcome to Lambda Tutorial by Edureka!"); } }
  • 10. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Lambda Parameters Lambda Expressions can take parameters just like methods 1 2 3 Zero Parameters One Parameter Multiple Parameters
  • 11. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Lambda Parameters 1 2 3 Zero Parameters One Parameter Multiple Parameters
  • 12. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Lambda Parameters 1 2 3 Zero Parameters One Parameter Multiple Parameters () -> System.out.println("Zero parameter lambda");
  • 13. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Lambda Parameters 1 2 3 Zero Parameters One Parameter Multiple Parameters () -> System.out.println("Zero parameter lambda"); (param) -> System.out.println("One parameter: " + param);
  • 14. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Lambda Parameters 1 2 3 Zero Parameters One Parameter Multiple Parameters () -> System.out.println("Zero parameter lambda"); (param) -> System.out.println("One parameter: " + param); (p1, p2) -> System.out.println("Multiple parameters: " + p1 + ", " + p2);
  • 16. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Lambda as an Object A Java lambda expression is essentially an object that can be assigned to a variable and passed around public interface LambdaComparator { public boolean compare(int a1, int a2); } LambdaComparator myComparator = (a1, a2) -> return a1 > a2; boolean result = myComparator.compare(2, 5); Interface Implementing class
  • 18. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Variable Capture Java lambda expression can access variables that are declared outside the lambda function body under certain circumstances 1 2 3 Local Variable Instance Variables Static Variables
  • 19. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Lambda Parameters 1 2 3 Local Variable Instance Variables Static Variables
  • 20. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Lambda Parameters 1 2 3 Local Variable String myStr = "Welcome to Edureka!"; MyLambda dis = (chars) -> { return myStr + ":" + new String(chars); }; Instance Variables Static Variables
  • 21. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Lambda Parameters 1 2 3 Local Variable Instance Variables Static Variables public class LambdaStaticConsumerDemo { private String str = "Lambda Consumer"; public void attach(LambdaStaticProducerDemo eventProd){ eventProd.listen(e -> { System.out.println(this.str); }); } }
  • 22. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Lambda Parameters 1 2 3 Local Variable Instance Variables Static Variables public class LambdaStaticConsumerDemo { private static String myStaticVar = "Edureka!"; public void attach(LambdaStaticProducerDemo eventProd){ eventProd.listen(e -> { System.out.println(myStaticVar); }); } }
  • 24. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Method References Java lambda expression can access variables that are declared outside the lambda function body under certain circumstances Static Method Reference 1 2 3 4 Parameter Method Reference Instance Method Reference Constructor Method Reference
  • 25. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Method References Static Method Reference 1 2 3 4 Parameter Method Reference Instance Method Reference Constructor Method Reference
  • 26. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Class Lambda Expression Interface Method References - Static Static Method Reference1 2 3 4 Parameter Method Reference Instance Method Reference Constructor Method Reference public interface Display { public int show(String s1, String s2); } public class Test{ public static int doShow(String s1, String s2){ return s1.lastIndexOf(s2); } } Display disp = Test::doShow;
  • 27. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Method References - Parameter Static Method Reference 1 2 3 4 Parameter Method Reference Instance Method Reference Constructor Method Reference Interface public interface Display { public int show(String s1, String s2); } Lambda Expression Display disp = String::indexOf;
  • 28. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Method References - Instance Static Method Reference 1 2 3 4 Parameter Method Reference Instance Method Reference Constructor Method Reference Interface public interface Deserializer { public int deserialize(String v1); } Class Lambda Expression public class StringConverter { public int convertToInt(String v1){ return Integer.valueOf(v1); } } StringConverter strConv = new StringConverter(); Deserializer deserializer = strConv::convertToInt;
  • 29. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Method References - Constructor Static Method Reference 1 2 3 4 Parameter Method Reference Instance Method Reference Constructor Method Reference Interface public interface Factory { public String create(char[] val); } Lambda Expression Factory fact = String::new;