SlideShare a Scribd company logo
Lambda, Method References & 
Aggregate Operations 
Md. Fasihul Kabir 
Software Engineer, Platform Dhaka, Escenic Asia Ltd.
Some Cool Features of Java 8 
 Lambda expressions 
 Method references 
 Default Methods (Defender methods) 
 A new Stream API 
 Optional 
 A new Date/Time API 
 Nashorn, the new JavaScript engine 
 Removal of the Permanent Generation 
 and more…
Some Cool Features of Java 8 
 Lambda Expressions 
 Method References 
 Default Methods (Defender methods) 
 A new Stream API 
 Optional 
 A new Date/Time API 
 Nashorn, the new JavaScript engine 
 Removal of the Permanent Generation 
 and more…
Lambda Expressions
Syntax 
(arguments) - {body}
Example 
button.addActionListener(new ActionListener(){ 
public void actionPerformed(ActionEvent event){ 
System.out.println(button clicked); 
} 
});
button.addActionListener(new ActionListener(){ 
public void actionPerformed(ActionEvent event){ 
System.out.println(button clicked); 
} 
});
button.addActionListener( 
event - System.out.println(button clicked) 
);
Structure of Lambda Expressions 
 A lambda expression can have zero, one or more parameters 
 The type of the parameters can be explicitly declared or it can be inferred from the 
context. 
e.g. (int a) is same as just (a) 
 Parameters are enclosed in parentheses and separated by commas. 
e.g. (a, b) or (int a, int b) or (String a, int b, float c) 
 Empty parentheses are used to represent an empty set of parameters. 
e.g. () - 42 
 When there is a single parameter, if its type is inferred, it is not mandatory to use 
parentheses 
e.g. a - return a*a 
 The body of the lambda expressions can contain zero, one or more statements 
 If body of lambda expression has single statement curly brackets are not mandatory and 
the return type of the anonymous function is the same as that of the body expression 
 When there is more than one statement in body than these must be enclosed in curly 
brackets (a code block) and the return type of the anonymous function is the same as 
the type of the value returned within the code block, or void if nothing is returned
Method References
Java 8
Java 8
Java 8
Java 8
Java 8
Kinds of Method References 
Kind Example 
Reference to a static method ContainingClass::staticMethodName 
Reference to an instance method of a 
particular object 
containingObject::instanceMethodName 
Reference to an instance method of an 
arbitrary object of a particular type 
ContainingType::methodName 
Reference to a constructor ClassName::new
Reference to a Static Method 
 The method reference Person::compareByAge is a 
reference to a static method.
Reference to an Instance Method of a 
Particular Object
Reference to an Instance Method of an 
Arbitrary Object of a Particular Type
Reference to a Constructor
Java 8
Java 8
Aggregate Operations
Java 8
Java 8
Java 8
Pipelines and Streams
Components of Pipeline 
 A source: This could be a collection, an array, a 
generator function, or an I/O channel. In this example, 
the source is the collection roster. 
 Zero or more intermediate operations. An intermediate 
operation, such as filter, produces a new stream. 
 A terminal operation. A terminal operation, such as 
forEach, produces a non-stream result, such as a 
primitive value (like a double value), a collection, or in 
the case of forEach, no value at all.
Java 8
Java 8
Java 8

More Related Content

PPTX
Java 8 - Features Overview
Sergii Stets
 
PDF
Java 8 - Project Lambda
Rahman USTA
 
PPT
Module 3: Introduction to LINQ (PowerPoint Slides)
Mohamed Saleh
 
DOCX
QTP AUTOMATION TESTING SYLLABUS
SHPINE TECHNOLOGIES
 
PPTX
Link quries
ulfat mushtaq
 
PPT
Linq
Vishwa Mohan
 
PDF
Java8 features
Elias Hasnat
 
PPTX
Method overloading
VaibhavSingh531
 
Java 8 - Features Overview
Sergii Stets
 
Java 8 - Project Lambda
Rahman USTA
 
Module 3: Introduction to LINQ (PowerPoint Slides)
Mohamed Saleh
 
QTP AUTOMATION TESTING SYLLABUS
SHPINE TECHNOLOGIES
 
Link quries
ulfat mushtaq
 
Java8 features
Elias Hasnat
 
Method overloading
VaibhavSingh531
 

What's hot (20)

PDF
Lambda expression par Christophe Huntzinger
Mik_Arber
 
PPTX
Mule java part-3
Ravinder Singh
 
PPTX
Java in mule part 3
vasanthii9
 
PPTX
Module 13 operators, delegates, and events
Prem Kumar Badri
 
PPT
Understanding linq
Anand Kumar Rajana
 
PDF
Lambda/Streams Hands-On Lab
Maurice Naftalin
 
PPTX
Scope demystified - AngularJS
Sumanth krishna
 
PPTX
Resharper - Next Steps
Timmy Kokke
 
PPTX
GraphQL Misconfiguration
Harshit Sengar
 
PPTX
Java 8 lambda
Manav Prasad
 
PPTX
Java 8 presentation
Van Huong
 
PPTX
Attacking GraphQL
KavishaSheth1
 
ODP
Introduction to Java 8
Knoldus Inc.
 
PPTX
java 8 new features
Rohit Verma
 
PDF
Scala Code Analysis at Codacy
Johann Oikonomou
 
PDF
Java 8 Lambda Expressions & Streams
NewCircle Training
 
PPTX
Mule java part-3
Karnam Karthik
 
PPTX
2CPP08 - Overloading and Overriding
Michael Heron
 
PDF
Java8
Felipe Mamud
 
PPTX
Применение паттерна Page Object для автоматизации веб сервисов
COMAQA.BY
 
Lambda expression par Christophe Huntzinger
Mik_Arber
 
Mule java part-3
Ravinder Singh
 
Java in mule part 3
vasanthii9
 
Module 13 operators, delegates, and events
Prem Kumar Badri
 
Understanding linq
Anand Kumar Rajana
 
Lambda/Streams Hands-On Lab
Maurice Naftalin
 
Scope demystified - AngularJS
Sumanth krishna
 
Resharper - Next Steps
Timmy Kokke
 
GraphQL Misconfiguration
Harshit Sengar
 
Java 8 lambda
Manav Prasad
 
Java 8 presentation
Van Huong
 
Attacking GraphQL
KavishaSheth1
 
Introduction to Java 8
Knoldus Inc.
 
java 8 new features
Rohit Verma
 
Scala Code Analysis at Codacy
Johann Oikonomou
 
Java 8 Lambda Expressions & Streams
NewCircle Training
 
Mule java part-3
Karnam Karthik
 
2CPP08 - Overloading and Overriding
Michael Heron
 
Применение паттерна Page Object для автоматизации веб сервисов
COMAQA.BY
 
Ad

Viewers also liked (20)

PPTX
Tina Turner La Regina del Rock and Roll
rockandrollboxmay21
 
PPTX
Grafixoft ltd
Grafixoft
 
PPTX
Andreas Ocklenburg, Cloudsme AG, DE
I4MS_eu
 
PPTX
Introduction about GIT
mentallog
 
PPTX
Grafixoft solutions
Grafixoft
 
DOCX
Infark
Anggita Oksyrana
 
PPTX
Evaluation Feedback
mnatasha1
 
PPTX
Social work
Ramanand Kalathingal
 
PDF
Webaula 1
daniela oliveira
 
PPTX
AGENSI PBB
Fad Deen
 
PPT
Chapter 5 pc
Hanif Durad
 
PPT
Chapter 4 pc
Hanif Durad
 
PPSX
Prezentare Asociatia Tineretul ONU din Romania - Filiala Banat
UNYouthBanatBranch
 
PPTX
Indian Jugaad Technology (Frugal Engineering)
Javed Rizvi
 
PPT
Collective Communications in MPI
Hanif Durad
 
PPT
Chapter 2 pc
Hanif Durad
 
PDF
Break out game
mentallog
 
PDF
Gnito Deck
Gnito
 
PPTX
Façade pattern
mentallog
 
PPS
Establishing Rapport
Simone Becker
 
Tina Turner La Regina del Rock and Roll
rockandrollboxmay21
 
Grafixoft ltd
Grafixoft
 
Andreas Ocklenburg, Cloudsme AG, DE
I4MS_eu
 
Introduction about GIT
mentallog
 
Grafixoft solutions
Grafixoft
 
Evaluation Feedback
mnatasha1
 
Webaula 1
daniela oliveira
 
AGENSI PBB
Fad Deen
 
Chapter 5 pc
Hanif Durad
 
Chapter 4 pc
Hanif Durad
 
Prezentare Asociatia Tineretul ONU din Romania - Filiala Banat
UNYouthBanatBranch
 
Indian Jugaad Technology (Frugal Engineering)
Javed Rizvi
 
Collective Communications in MPI
Hanif Durad
 
Chapter 2 pc
Hanif Durad
 
Break out game
mentallog
 
Gnito Deck
Gnito
 
Façade pattern
mentallog
 
Establishing Rapport
Simone Becker
 
Ad

Similar to Java 8 (20)

PPTX
Java 8 Lambda Expressions
Hyderabad Scalability Meetup
 
PDF
Unit-3.pptx.pdf java api knowledge apiii
mpfbaa
 
PPTX
java150929145120-lva1-app6892 (2).pptx
BruceLee275640
 
PPT
C0 review core java1
tam53pm1
 
PPTX
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
vekariyakashyap
 
PDF
What's new in java 8
Dian Aditya
 
PPT
Ap Power Point Chpt4
dplunkett
 
PPTX
Chap-2 Classes & Methods.pptx
chetanpatilcp783
 
PPTX
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Emiel Paasschens
 
PDF
Java8: Language Enhancements
Yuriy Bondaruk
 
PPTX
Java8 training - Class 1
Marut Singh
 
PDF
Beyond Java: 자바 8을 중심으로 본 자바의 혁신
Sungchul Park
 
PPT
Slides
Videoguy
 
PPT
Java findamentals1
Todor Kolev
 
PPT
Java findamentals1
Todor Kolev
 
PPT
Java findamentals1
Todor Kolev
 
PDF
Functional Vaadin talk at OSCON 2014
hezamu
 
PDF
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Edureka!
 
DOCX
Colloquium Report
Mohammad Faizan
 
PPTX
Java 8 Intro - Core Features
GlobalLogic Ukraine
 
Java 8 Lambda Expressions
Hyderabad Scalability Meetup
 
Unit-3.pptx.pdf java api knowledge apiii
mpfbaa
 
java150929145120-lva1-app6892 (2).pptx
BruceLee275640
 
C0 review core java1
tam53pm1
 
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
vekariyakashyap
 
What's new in java 8
Dian Aditya
 
Ap Power Point Chpt4
dplunkett
 
Chap-2 Classes & Methods.pptx
chetanpatilcp783
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Emiel Paasschens
 
Java8: Language Enhancements
Yuriy Bondaruk
 
Java8 training - Class 1
Marut Singh
 
Beyond Java: 자바 8을 중심으로 본 자바의 혁신
Sungchul Park
 
Slides
Videoguy
 
Java findamentals1
Todor Kolev
 
Java findamentals1
Todor Kolev
 
Java findamentals1
Todor Kolev
 
Functional Vaadin talk at OSCON 2014
hezamu
 
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Edureka!
 
Colloquium Report
Mohammad Faizan
 
Java 8 Intro - Core Features
GlobalLogic Ukraine
 

Recently uploaded (20)

PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
PDF
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
PDF
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
PDF
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
DOCX
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PDF
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PDF
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
PDF
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
PPTX
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPTX
Presentation about variables and constant.pptx
safalsingh810
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PDF
Immersive experiences: what Pharo users do!
ESUG
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
Presentation about variables and constant.pptx
kr2589474
 
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Presentation about variables and constant.pptx
safalsingh810
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
Immersive experiences: what Pharo users do!
ESUG
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 

Java 8

  • 1. Lambda, Method References & Aggregate Operations Md. Fasihul Kabir Software Engineer, Platform Dhaka, Escenic Asia Ltd.
  • 2. Some Cool Features of Java 8 Lambda expressions Method references Default Methods (Defender methods) A new Stream API Optional A new Date/Time API Nashorn, the new JavaScript engine Removal of the Permanent Generation and more…
  • 3. Some Cool Features of Java 8 Lambda Expressions Method References Default Methods (Defender methods) A new Stream API Optional A new Date/Time API Nashorn, the new JavaScript engine Removal of the Permanent Generation and more…
  • 6. Example button.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent event){ System.out.println(button clicked); } });
  • 7. button.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent event){ System.out.println(button clicked); } });
  • 8. button.addActionListener( event - System.out.println(button clicked) );
  • 9. Structure of Lambda Expressions A lambda expression can have zero, one or more parameters The type of the parameters can be explicitly declared or it can be inferred from the context. e.g. (int a) is same as just (a) Parameters are enclosed in parentheses and separated by commas. e.g. (a, b) or (int a, int b) or (String a, int b, float c) Empty parentheses are used to represent an empty set of parameters. e.g. () - 42 When there is a single parameter, if its type is inferred, it is not mandatory to use parentheses e.g. a - return a*a The body of the lambda expressions can contain zero, one or more statements If body of lambda expression has single statement curly brackets are not mandatory and the return type of the anonymous function is the same as that of the body expression When there is more than one statement in body than these must be enclosed in curly brackets (a code block) and the return type of the anonymous function is the same as the type of the value returned within the code block, or void if nothing is returned
  • 16. Kinds of Method References Kind Example Reference to a static method ContainingClass::staticMethodName Reference to an instance method of a particular object containingObject::instanceMethodName Reference to an instance method of an arbitrary object of a particular type ContainingType::methodName Reference to a constructor ClassName::new
  • 17. Reference to a Static Method The method reference Person::compareByAge is a reference to a static method.
  • 18. Reference to an Instance Method of a Particular Object
  • 19. Reference to an Instance Method of an Arbitrary Object of a Particular Type
  • 20. Reference to a Constructor
  • 28. Components of Pipeline A source: This could be a collection, an array, a generator function, or an I/O channel. In this example, the source is the collection roster. Zero or more intermediate operations. An intermediate operation, such as filter, produces a new stream. A terminal operation. A terminal operation, such as forEach, produces a non-stream result, such as a primitive value (like a double value), a collection, or in the case of forEach, no value at all.