SlideShare una empresa de Scribd logo
1 de 29
Descargar para leer sin conexión
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
????
???
??
?

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Java8 features
Java8 featuresJava8 features
Java8 features
 
Major Java 8 features
Major Java 8 featuresMajor Java 8 features
Major Java 8 features
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Java 8 Feature Preview
Java 8 Feature PreviewJava 8 Feature Preview
Java 8 Feature Preview
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Java8
Java8Java8
Java8
 
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
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New Features
 
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
 
Java 8 streams
Java 8 streamsJava 8 streams
Java 8 streams
 
Java 8 Streams And Common Operations By Harmeet Singh(Taara)
Java 8 Streams And Common Operations By Harmeet Singh(Taara)Java 8 Streams And Common Operations By Harmeet Singh(Taara)
Java 8 Streams And Common Operations By Harmeet Singh(Taara)
 
Introduction to Java 8
Introduction to Java 8Introduction to Java 8
Introduction to Java 8
 
Java 8 new features
Java 8 new featuresJava 8 new features
Java 8 new features
 
Java 8: the good parts!
Java 8: the good parts!Java 8: the good parts!
Java 8: the good parts!
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8
 
Streams in Java 8
Streams in Java 8Streams in Java 8
Streams in Java 8
 
Functional Programming In Practice
Functional Programming In PracticeFunctional Programming In Practice
Functional Programming In Practice
 

Destacado

Slideshare Power Point Sunumu
Slideshare Power Point SunumuSlideshare Power Point Sunumu
Slideshare Power Point Sunumu
guest5b8685
 
SLİDESHARE NASIL KULLANILIR?
SLİDESHARE NASIL KULLANILIR?SLİDESHARE NASIL KULLANILIR?
SLİDESHARE NASIL KULLANILIR?
Orkun Güren
 

Destacado (11)

Slideshare Power Point Sunumu
Slideshare Power Point SunumuSlideshare Power Point Sunumu
Slideshare Power Point Sunumu
 
Slideshare nedir
Slideshare nedirSlideshare nedir
Slideshare nedir
 
SLİDESHARE NASIL KULLANILIR?
SLİDESHARE NASIL KULLANILIR?SLİDESHARE NASIL KULLANILIR?
SLİDESHARE NASIL KULLANILIR?
 
Slideshare net
Slideshare netSlideshare net
Slideshare net
 
Git - Bildiğiniz Gibi Değil
Git - Bildiğiniz Gibi DeğilGit - Bildiğiniz Gibi Değil
Git - Bildiğiniz Gibi Değil
 
Java Exception Handling Best Practices - Improved Second Version
Java Exception Handling Best Practices - Improved Second VersionJava Exception Handling Best Practices - Improved Second Version
Java Exception Handling Best Practices - Improved Second Version
 
Digital Sketchnotes 101
Digital Sketchnotes 101Digital Sketchnotes 101
Digital Sketchnotes 101
 
Snapchat Visual Marketing Strategy
Snapchat Visual Marketing StrategySnapchat Visual Marketing Strategy
Snapchat Visual Marketing Strategy
 
The Sketchnote Mini-Workshop
The Sketchnote Mini-WorkshopThe Sketchnote Mini-Workshop
The Sketchnote Mini-Workshop
 
Clean and green hydrocarbons ignite publish
Clean and green hydrocarbons ignite publishClean and green hydrocarbons ignite publish
Clean and green hydrocarbons ignite publish
 
17 Ways to Design a Presentation People Want to View
17 Ways to Design a Presentation People Want to View17 Ways to Design a Presentation People Want to View
17 Ways to Design a Presentation People Want to View
 

Similar a Java 8 - Project Lambda

Java tutorials
Java tutorialsJava tutorials
Java tutorials
saryu2011
 
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon RitterLambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
JAXLondon2014
 

Similar a Java 8 - Project Lambda (20)

Lambdas in Java 8
Lambdas in Java 8Lambdas in Java 8
Lambdas in Java 8
 
Collections
CollectionsCollections
Collections
 
Lambdas and Laughs
Lambdas and LaughsLambdas and Laughs
Lambdas and Laughs
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
Lambdas : Beyond The Basics
Lambdas : Beyond The BasicsLambdas : Beyond The Basics
Lambdas : Beyond The Basics
 
Automatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesAutomatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to Interfaces
 
The Road to Lambda - Mike Duigou
The Road to Lambda - Mike DuigouThe Road to Lambda - Mike Duigou
The Road to Lambda - Mike Duigou
 
Charles Sharp: Java 8 Streams
Charles Sharp: Java 8 StreamsCharles Sharp: Java 8 Streams
Charles Sharp: Java 8 Streams
 
Java 8 Intro - Core Features
Java 8 Intro - Core FeaturesJava 8 Intro - Core Features
Java 8 Intro - Core Features
 
Java tutorials
Java tutorialsJava tutorials
Java tutorials
 
08 subprograms
08 subprograms08 subprograms
08 subprograms
 
JDK8 Lambdas and Streams: Changing The Way You Think When Developing Java
JDK8 Lambdas and Streams: Changing The Way You Think When Developing JavaJDK8 Lambdas and Streams: Changing The Way You Think When Developing Java
JDK8 Lambdas and Streams: Changing The Way You Think When Developing Java
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.
 
Java 8
Java 8Java 8
Java 8
 
Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud Foundry
 
Stream Api.pdf
Stream Api.pdfStream Api.pdf
Stream Api.pdf
 
Modern_Java_Workshop manjunath np hj slave
Modern_Java_Workshop manjunath np hj slaveModern_Java_Workshop manjunath np hj slave
Modern_Java_Workshop manjunath np hj slave
 
JavaTutorials.ppt
JavaTutorials.pptJavaTutorials.ppt
JavaTutorials.ppt
 
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon RitterLambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
 
Lambdas And Streams in JDK8
Lambdas And Streams in JDK8Lambdas And Streams in JDK8
Lambdas And Streams in JDK8
 

Más de Rahman USTA

Más de Rahman USTA (6)

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

Último

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
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+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...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

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
 
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 ...
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
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)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
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
 
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
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
"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 ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
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
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
+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...
 

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 ???? ??? ?? ?