SlideShare a Scribd company logo
Revolution of Java
Java 8 – Project Lambda
About Me
• Java Developer
• Technical Teacher
• Blogger @kodcu.com
Java 8 Innovations

• Lambda Expressions

• Type Inference

• Metod References

• Collection II

• Defender Methods
Functional Interface ?
• An Interface includes only one abstract
  method called as FunctionalInterface


• Lambda expressions are converted to a FI’s
  implementation in Background
Functional Interface Examps.
• java.lang.Runnable
• java.util.concurrent.Callable
• java.nio.file.PathMatcher
• java.lang.reflect.InvocationHandler
• java.beans.PropertyChangeListener
• java.awt.event.ActionListener
Lambda Expressions
• Lambda -> (also called Closures), is an expression
  that reduces vertical boilerplate code.

• Concise and Clear code development practice

• Interfaces that consist of one more than abstract
  method, cannot be counterpart of any Lambda
  expressions.

   Tip: Exceptions (Defender methods & Object class’ methods)
Focus to Input & Output
Runnable r1=new Runnable() {

        @Override             Input

        public void run() {

             Output

            System.out.println(“Hello Uranus.");

        }
   };
Example
Lambda Types

• 2 type
  – Single expression // no need “return”
     • (Integer s) -> ( s*2 );
     • |or| (Integer s) -> s*2 ;



  – Statement Block
     • (Integer s) -> { return s*2; };
Type Inference

(String s) -> { System.out.println(s); };
// equals

(s) -> { System.out.println(s); };
// equals

s   -> { System.out.println(s); };
Type Inference

(Integer   a, Integer b)    -> a + b;
// equals

(a,b) -> (a+b);
Metod References
Runnable r1=new Runnable() {

        @Override             Input

        public void run() {

             Output

            System.out.println(“Hello Uranus.");

        }
   };
Metod References
Collection II
• Collection II is an attachment to existing
  Collection Framework.

• Supports Jquery like chained methods and
  Underscore.js like Functional Programming
  Experience.
Collection II
• Existing Collection Framework does not
  support Concurrent operations in
  chunked datas.

• Cause, existing one applies External
  Iteration.
Stream <T> Interface
• Sequential and Consumable data structure.

• The data cannot be fetch again after consumed.

• A Stream object can be obtained any data
  structure in Collection Framework.

• Fo.Exm: LinkedList, ArrayList, HashSet.
java.util.function
         Functional Interfaces

• Those special Interfaces
  support general data
  operations.
Consumer<T> -> Applying
• Consumer gets an input and runs an action.

• Does not return any result, only do an action.



  public void accept(T t);
Predicate<T> -> Filtering
• Predicate gets a conditional code and
  produce -> true || false

• In concise, makes filtering.


  public boolean test(T t);
Function<T, R> -> (Consume & Produce);
• Gets any type of input object and Produce an
  output object.



     public R apply(T t);
Supplier<T>
• Do not get any argument object, only returns
  instantiation of any object type.



    public T get();
Bi?
BiPredicate<L, R>    Compares two inputted object.

BiConsumer<T, U>     Consumes two type of objects, and produce no result

BiFunction<T, U, R> Gets two input object (T , U) and produce a result (R)


                                   .
                                   .
                                   .
Parallel Stream
• Any parallelizable operations can run
  concurrently with Parallel stream object.

• Parallel Stream object can be obtain with
  parallelStream() method from any Streamable
  data structure.
Lazily & Eagerly Ops.
• Some Stream operations can be run Lazly as
  some Eagerly.
         Lazy          Eager

• .filter().map().allMatch();
                Lazy            Eager

• .filter().filter().sorted().forEach();
Lazily & Eagerly
• Lazy operations are evaluated together with
  first encountered Eager operation.

• The goal is evaluate chanied operations in
  one step.
Defender Methods
• Before Java 8, Interfaces can contain only
  abstract methods.

• With Java 8, any Interface can contain one or
  more concrete methods that named
  default/defender method.

• Tip: Default methods do not break nature of F           I
                                                  onctional nterfaces
Defender Methods

• Defender Methods, Default Methods, Virtual extension methods

• Makes possible usage of concrete methods.

• Makes more elastic of Java Inheritance model.
Defender Methods
• Defender methods can be re-implemented or
  inherited by other Interfaces.
?
??
???
????
?????   Q/A
????
???
??
?

More Related Content

What's hot (20)

PDF
Java8 features
Elias Hasnat
 
PPT
Major Java 8 features
Sanjoy Kumar Roy
 
PPTX
java 8 new features
Rohit Verma
 
PPTX
Java 8 presentation
Van Huong
 
PDF
Java 8 features
Oleg Tsal-Tsalko
 
PPTX
Java 8 Feature Preview
Jim Bethancourt
 
PPTX
Java 8 Features
Leninkumar Koppoju
 
PDF
Java 8 features
NexThoughts Technologies
 
PDF
Java8
Felipe Mamud
 
PPTX
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India
 
PPTX
Java SE 8 - New Features
Naveen Hegde
 
PDF
Functional programming in java 8 by harmeet singh
Harmeet Singh(Taara)
 
PPTX
Java 8 streams
Manav Prasad
 
PPTX
Java 8 Streams And Common Operations By Harmeet Singh(Taara)
Harmeet Singh(Taara)
 
ODP
Introduction to Java 8
Knoldus Inc.
 
PPTX
Java 8 new features
Aniket Thakur
 
PDF
Java 8: the good parts!
Andrzej Grzesik
 
PPTX
New Features in JDK 8
Martin Toshev
 
PDF
Streams in Java 8
Tobias Coetzee
 
PDF
Functional Programming In Practice
Michiel Borkent
 
Java8 features
Elias Hasnat
 
Major Java 8 features
Sanjoy Kumar Roy
 
java 8 new features
Rohit Verma
 
Java 8 presentation
Van Huong
 
Java 8 features
Oleg Tsal-Tsalko
 
Java 8 Feature Preview
Jim Bethancourt
 
Java 8 Features
Leninkumar Koppoju
 
Java 8 features
NexThoughts Technologies
 
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India
 
Java SE 8 - New Features
Naveen Hegde
 
Functional programming in java 8 by harmeet singh
Harmeet Singh(Taara)
 
Java 8 streams
Manav Prasad
 
Java 8 Streams And Common Operations By Harmeet Singh(Taara)
Harmeet Singh(Taara)
 
Introduction to Java 8
Knoldus Inc.
 
Java 8 new features
Aniket Thakur
 
Java 8: the good parts!
Andrzej Grzesik
 
New Features in JDK 8
Martin Toshev
 
Streams in Java 8
Tobias Coetzee
 
Functional Programming In Practice
Michiel Borkent
 

Viewers also liked (11)

PPT
Slideshare Power Point Sunumu
guest5b8685
 
PPT
Slideshare nedir
Ebru Üçüncü
 
PPT
SLİDESHARE NASIL KULLANILIR?
Orkun Güren
 
PPT
Slideshare net
Pavlow Vinelli
 
PDF
Git - Bildiğiniz Gibi Değil
Lemi Orhan Ergin
 
PDF
Java Exception Handling Best Practices - Improved Second Version
Lemi Orhan Ergin
 
PDF
Digital Sketchnotes 101
Karen Bosch
 
PDF
Snapchat Visual Marketing Strategy
Katai Robert
 
PDF
The Sketchnote Mini-Workshop
Mike Rohde
 
PDF
Clean and green hydrocarbons ignite publish
Krzysztof (Kris) Palka
 
PDF
17 Ways to Design a Presentation People Want to View
Jim MacLeod
 
Slideshare Power Point Sunumu
guest5b8685
 
Slideshare nedir
Ebru Üçüncü
 
SLİDESHARE NASIL KULLANILIR?
Orkun Güren
 
Slideshare net
Pavlow Vinelli
 
Git - Bildiğiniz Gibi Değil
Lemi Orhan Ergin
 
Java Exception Handling Best Practices - Improved Second Version
Lemi Orhan Ergin
 
Digital Sketchnotes 101
Karen Bosch
 
Snapchat Visual Marketing Strategy
Katai Robert
 
The Sketchnote Mini-Workshop
Mike Rohde
 
Clean and green hydrocarbons ignite publish
Krzysztof (Kris) Palka
 
17 Ways to Design a Presentation People Want to View
Jim MacLeod
 
Ad

Similar to Java 8 - Project Lambda (20)

PDF
Lambdas in Java 8
Tobias Coetzee
 
PPTX
Lambdas and Laughs
Jim Bethancourt
 
PPT
Java Tutorial
Singsys Pte Ltd
 
PPTX
Lambdas : Beyond The Basics
Simon Ritter
 
PDF
Automatic Migration of Legacy Java Method Implementations to Interfaces
Raffi Khatchadourian
 
PPTX
The Road to Lambda - Mike Duigou
jaxconf
 
PDF
Charles Sharp: Java 8 Streams
jessitron
 
PPTX
Java 8 Intro - Core Features
GlobalLogic Ukraine
 
PPT
Java tutorials
saryu2011
 
PDF
08 subprograms
baran19901990
 
PPTX
JDK8 Lambdas and Streams: Changing The Way You Think When Developing Java
Simon Ritter
 
ODP
Synapseindia reviews.odp.
Tarunsingh198
 
PPTX
Java 8
Sudipta K Paik
 
PPTX
Pptchdtdtfygugyxthgihhihigugufydtdfzrzrzrtdyfyfy
dnthulk
 
PPTX
Scala, Play 2.0 & Cloud Foundry
Pray Desai
 
PDF
Stream Api.pdf
Akaks
 
PPTX
Modern_Java_Workshop manjunath np hj slave
gangadharnp111
 
PPT
JavaTutorials.ppt
Khizar40
 
PDF
Lambdas And Streams in JDK8
Simon Ritter
 
Lambdas in Java 8
Tobias Coetzee
 
Lambdas and Laughs
Jim Bethancourt
 
Java Tutorial
Singsys Pte Ltd
 
Lambdas : Beyond The Basics
Simon Ritter
 
Automatic Migration of Legacy Java Method Implementations to Interfaces
Raffi Khatchadourian
 
The Road to Lambda - Mike Duigou
jaxconf
 
Charles Sharp: Java 8 Streams
jessitron
 
Java 8 Intro - Core Features
GlobalLogic Ukraine
 
Java tutorials
saryu2011
 
08 subprograms
baran19901990
 
JDK8 Lambdas and Streams: Changing The Way You Think When Developing Java
Simon Ritter
 
Synapseindia reviews.odp.
Tarunsingh198
 
Pptchdtdtfygugyxthgihhihigugufydtdfzrzrzrtdyfyfy
dnthulk
 
Scala, Play 2.0 & Cloud Foundry
Pray Desai
 
Stream Api.pdf
Akaks
 
Modern_Java_Workshop manjunath np hj slave
gangadharnp111
 
JavaTutorials.ppt
Khizar40
 
Lambdas And Streams in JDK8
Simon Ritter
 
Ad

More from Rahman USTA (6)

PDF
JShell: The Ultimate Missing Tool
Rahman USTA
 
PDF
Digital Authoring with Asciidoc(tor) and AsciidocFX
Rahman USTA
 
PDF
JavaOne 2016 - The JCP (Java Community Process)
Rahman USTA
 
PDF
Java 9 Project Jigsaw
Rahman USTA
 
PDF
Java EE Nedir? (Baku JUG)
Rahman USTA
 
PPTX
Java 8 Nashorn ve Avatar.js
Rahman USTA
 
JShell: The Ultimate Missing Tool
Rahman USTA
 
Digital Authoring with Asciidoc(tor) and AsciidocFX
Rahman USTA
 
JavaOne 2016 - The JCP (Java Community Process)
Rahman USTA
 
Java 9 Project Jigsaw
Rahman USTA
 
Java EE Nedir? (Baku JUG)
Rahman USTA
 
Java 8 Nashorn ve Avatar.js
Rahman USTA
 

Recently uploaded (20)

PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Digital Circuits, important subject in CS
contactparinay1
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 

Java 8 - Project Lambda

  • 1. Revolution of Java Java 8 – Project Lambda
  • 2. About Me • Java Developer • Technical Teacher • Blogger @kodcu.com
  • 3. Java 8 Innovations • Lambda Expressions • Type Inference • Metod References • Collection II • Defender Methods
  • 4. Functional Interface ? • An Interface includes only one abstract method called as FunctionalInterface • Lambda expressions are converted to a FI’s implementation in Background
  • 5. Functional Interface Examps. • java.lang.Runnable • java.util.concurrent.Callable • java.nio.file.PathMatcher • java.lang.reflect.InvocationHandler • java.beans.PropertyChangeListener • java.awt.event.ActionListener
  • 6. Lambda Expressions • Lambda -> (also called Closures), is an expression that reduces vertical boilerplate code. • Concise and Clear code development practice • Interfaces that consist of one more than abstract method, cannot be counterpart of any Lambda expressions. Tip: Exceptions (Defender methods & Object class’ methods)
  • 7. Focus to Input & Output Runnable r1=new Runnable() { @Override Input public void run() { Output System.out.println(“Hello Uranus."); } };
  • 9. Lambda Types • 2 type – Single expression // no need “return” • (Integer s) -> ( s*2 ); • |or| (Integer s) -> s*2 ; – Statement Block • (Integer s) -> { return s*2; };
  • 10. Type Inference (String s) -> { System.out.println(s); }; // equals (s) -> { System.out.println(s); }; // equals s -> { System.out.println(s); };
  • 11. Type Inference (Integer a, Integer b) -> a + b; // equals (a,b) -> (a+b);
  • 12. Metod References Runnable r1=new Runnable() { @Override Input public void run() { Output System.out.println(“Hello Uranus."); } };
  • 14. Collection II • Collection II is an attachment to existing Collection Framework. • Supports Jquery like chained methods and Underscore.js like Functional Programming Experience.
  • 15. Collection II • Existing Collection Framework does not support Concurrent operations in chunked datas. • Cause, existing one applies External Iteration.
  • 16. Stream <T> Interface • Sequential and Consumable data structure. • The data cannot be fetch again after consumed. • A Stream object can be obtained any data structure in Collection Framework. • Fo.Exm: LinkedList, ArrayList, HashSet.
  • 17. java.util.function Functional Interfaces • Those special Interfaces support general data operations.
  • 18. Consumer<T> -> Applying • Consumer gets an input and runs an action. • Does not return any result, only do an action. public void accept(T t);
  • 19. Predicate<T> -> Filtering • Predicate gets a conditional code and produce -> true || false • In concise, makes filtering. public boolean test(T t);
  • 20. Function<T, R> -> (Consume & Produce); • Gets any type of input object and Produce an output object. public R apply(T t);
  • 21. Supplier<T> • Do not get any argument object, only returns instantiation of any object type. public T get();
  • 22. Bi? BiPredicate<L, R> Compares two inputted object. BiConsumer<T, U> Consumes two type of objects, and produce no result BiFunction<T, U, R> Gets two input object (T , U) and produce a result (R) . . .
  • 23. Parallel Stream • Any parallelizable operations can run concurrently with Parallel stream object. • Parallel Stream object can be obtain with parallelStream() method from any Streamable data structure.
  • 24. Lazily & Eagerly Ops. • Some Stream operations can be run Lazly as some Eagerly. Lazy Eager • .filter().map().allMatch(); Lazy Eager • .filter().filter().sorted().forEach();
  • 25. Lazily & Eagerly • Lazy operations are evaluated together with first encountered Eager operation. • The goal is evaluate chanied operations in one step.
  • 26. Defender Methods • Before Java 8, Interfaces can contain only abstract methods. • With Java 8, any Interface can contain one or more concrete methods that named default/defender method. • Tip: Default methods do not break nature of F I onctional nterfaces
  • 27. Defender Methods • Defender Methods, Default Methods, Virtual extension methods • Makes possible usage of concrete methods. • Makes more elastic of Java Inheritance model.
  • 28. Defender Methods • Defender methods can be re-implemented or inherited by other Interfaces.
  • 29. ? ?? ??? ???? ????? Q/A ???? ??? ?? ?