SlideShare una empresa de Scribd logo
1 de 13
Copyright © 2014-2016 JavaBrahman.com
Introduction
to
Functional Programming
with Java-8
Dhruv Rai Puri
JavaBrahman.com
Copyright © 2014-2016 JavaBrahman.com
HELLO!
I am Dhruv Rai Puri
I am a Java Architect and run the technical blog JavaBrahman.com
You can reach me at
dhruvraipuri@javabrahman.com
Twitter~ @javabrahman
facebook.com/JavaBrahman
plus.google.com/+JavaBrahman
Copyright © 2014-2016 JavaBrahman.com
Whats going to be covered in this presentation
› Functional Programming
» What is functional programming
» How it’s different from imperative programming
› Important New Features in Java 8
› Functional Interfaces
› Lambda Expressions
Copyright © 2014-2016 JavaBrahman.com
What is Functional Programming
Focusses on
WHAT
is to be done
Subset of Declarative Style of Programming
Copyright © 2014-2016 JavaBrahman.com
Functional V/S Imperative
Programming
Style of Coding
Flow Control Mechanisms
Order of Execution Mutability of Variables
Primary Language Structures
Functions as 1st Class Objects
For in-depth understanding refer:
http://www.javabrahman.com/programming-principles/imperative-versus-functional-programming-paradigms-conceptual/
Copyright © 2014-2016 JavaBrahman.com
New Functional Features in Java – 8
Lambda Expressions
Eg:(String param)->{System.out.println("My lambda says "+param);};
Functional Interfaces
Eg: @FunctionalInterface
public interface Predicate<T> {
boolean test(T t);
}
(cont…)
Copyright © 2014-2016 JavaBrahman.com
New Functional Features in Java – 8(cont…)
Streams API
Eg: List filteredList = employeeList.stream()
.limit(2)
. collect(toList());
Method References
Eg: Function doubleConvertor=Double::parseDouble;
Constructor Reference: <ClassName>::new
For learning all new features in Java-8 refer:
http://www.javabrahman.com/java-8/new-features-in-java-8/
Copyright © 2014-2016 JavaBrahman.com
Functional Interfaces
› interface which has only a single abstract method
3 Types of functional interfaces
public interface CustomFunctionalInterface {
public void firstMethod();
}
1› Custom or User Defined
(cont…)
Copyright © 2014-2016 JavaBrahman.com
Functional Interfaces(cont..)
For learning in-depth about functional interfaces refer:
http://www.javabrahman.com/java-8/functional-interfaces-java-8/
//java.util.function.Predicate<T>
@FunctionalInterface
public interface Predicate<T> {
boolean test(T t);
}
2› Newly defined functional interfaces in Java 8
@FunctionalInterface
public interface Runnable {
public abstract void run();
}
3› Pre-existing functional interfaces in Java
Copyright © 2014-2016 JavaBrahman.com
Lambda Expressions
For learning in-depth about lambda expressions refer:
http://www.javabrahman.com/java-8/lambda-expressions-java-8-explained-examples/
› anonymous function which can be passed around as a
parameter thus achieving Behavior Parameterization
@FunctionalInterface
public interface FirstInterface {
//the abstract method
public void singleMethod(String param);
}
(String param)->{System.out.println("My lambda says "+param);};
Functional Interface
Corresponding Lambda Expressions
Copyright © 2014-2016 JavaBrahman.com
Q & A
Copyright © 2014-2016 JavaBrahman.com
For further reading on Java-8
 http://www.javabrahman.com/java-8/new-features-in-java-8/
 http://www.javabrahman.com/java-8/functional-interfaces-java-8/
 http://www.javabrahman.com/java-8/lambda-expressions-java-8-explained-examples/
 http://www.javabrahman.com/java-8/java-8-method-references-tutorial-examples/
 http://www.javabrahman.com/java-8/constructor-references-java-8-simplified-tutorial/
 http://www.javabrahman.com/java-8/java-8-streams-api-tutorial-with-examples/
Copyright © 2014-2016 JavaBrahman.com
Thank You

Más contenido relacionado

La actualidad más candente

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)
 
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)Harmeet Singh(Taara)
 
Functional programming with Xtend
Functional programming with XtendFunctional programming with Xtend
Functional programming with XtendSven Efftinge
 
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
 
Xtend - better java with -less- noise
Xtend - better java with -less- noiseXtend - better java with -less- noise
Xtend - better java with -less- noiseNeeraj Bhusare
 
Introduction to functional programming, with Elixir
Introduction to functional programming,  with ElixirIntroduction to functional programming,  with Elixir
Introduction to functional programming, with Elixirkirandanduprolu
 
JavaScript Introductin to Functions
JavaScript Introductin to FunctionsJavaScript Introductin to Functions
JavaScript Introductin to FunctionsCharles Russell
 
Scala - the good, the bad and the very ugly
Scala - the good, the bad and the very uglyScala - the good, the bad and the very ugly
Scala - the good, the bad and the very uglyBozhidar Bozhanov
 
Learn To Code: Introduction to c
Learn To Code: Introduction to cLearn To Code: Introduction to c
Learn To Code: Introduction to cSadhanaParameswaran
 
Functional programming
Functional programmingFunctional programming
Functional programmingPiumiPerera7
 
Intro to java 8
Intro to java 8Intro to java 8
Intro to java 8John Godoi
 

La actualidad más candente (20)

Lambdas
LambdasLambdas
Lambdas
 
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 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)
 
Insight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FPInsight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FP
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Functional programming with Xtend
Functional programming with XtendFunctional programming with Xtend
Functional programming with Xtend
 
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
 
Xtend - better java with -less- noise
Xtend - better java with -less- noiseXtend - better java with -less- noise
Xtend - better java with -less- noise
 
Xtext Webinar
Xtext WebinarXtext Webinar
Xtext Webinar
 
Introduction to functional programming, with Elixir
Introduction to functional programming,  with ElixirIntroduction to functional programming,  with Elixir
Introduction to functional programming, with Elixir
 
JavaScript Introductin to Functions
JavaScript Introductin to FunctionsJavaScript Introductin to Functions
JavaScript Introductin to Functions
 
Scala - the good, the bad and the very ugly
Scala - the good, the bad and the very uglyScala - the good, the bad and the very ugly
Scala - the good, the bad and the very ugly
 
PHP 5
PHP 5PHP 5
PHP 5
 
Learn To Code: Introduction to c
Learn To Code: Introduction to cLearn To Code: Introduction to c
Learn To Code: Introduction to c
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Plpgsql russia-pgconf
Plpgsql russia-pgconfPlpgsql russia-pgconf
Plpgsql russia-pgconf
 
Intro to java 8
Intro to java 8Intro to java 8
Intro to java 8
 
Web programming
Web programmingWeb programming
Web programming
 
Java 8
Java 8Java 8
Java 8
 
Functional Programming in Java
Functional Programming in JavaFunctional Programming in Java
Functional Programming in Java
 

Similar a Introduction to functional programming with java 8

Example Of Import Java
Example Of Import JavaExample Of Import Java
Example Of Import JavaMelody Rios
 
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 RitterJAXLondon2014
 
Lambdas And Streams in JDK8
Lambdas And Streams in JDK8Lambdas And Streams in JDK8
Lambdas And Streams in JDK8Simon Ritter
 
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...jaxLondonConference
 
BDX 2016 - Tzach zohar @ kenshoo
BDX 2016 - Tzach zohar  @ kenshooBDX 2016 - Tzach zohar  @ kenshoo
BDX 2016 - Tzach zohar @ kenshooIdo Shilon
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8javafxpert
 
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
 
REST Architectural Style: A Detail Explain
REST Architectural Style: A Detail ExplainREST Architectural Style: A Detail Explain
REST Architectural Style: A Detail ExplainNguyen Cao
 
Why Functional Programming So Hard?
Why Functional Programming So Hard?Why Functional Programming So Hard?
Why Functional Programming So Hard?Ilya Sidorov
 
Integrating Social Apps with Content Driven Sites using Apache Rave and Sprin...
Integrating Social Apps with Content Driven Sites using Apache Rave and Sprin...Integrating Social Apps with Content Driven Sites using Apache Rave and Sprin...
Integrating Social Apps with Content Driven Sites using Apache Rave and Sprin...ate.douma
 
Functional programming with_jdk8-s_ritter
Functional programming with_jdk8-s_ritterFunctional programming with_jdk8-s_ritter
Functional programming with_jdk8-s_ritterSimon Ritter
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014Nayden Gochev
 
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? reactima
 

Similar a Introduction to functional programming with java 8 (20)

Example Of Import Java
Example Of Import JavaExample Of Import Java
Example Of Import Java
 
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
 
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
 
BDX 2016 - Tzach zohar @ kenshoo
BDX 2016 - Tzach zohar  @ kenshooBDX 2016 - Tzach zohar  @ kenshoo
BDX 2016 - Tzach zohar @ kenshoo
 
Php OOP interview questions
Php OOP interview questionsPhp OOP interview questions
Php OOP interview questions
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8
 
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
 
REST Architectural Style: A Detail Explain
REST Architectural Style: A Detail ExplainREST Architectural Style: A Detail Explain
REST Architectural Style: A Detail Explain
 
Why Functional Programming So Hard?
Why Functional Programming So Hard?Why Functional Programming So Hard?
Why Functional Programming So Hard?
 
Integrating Social Apps with Content Driven Sites using Apache Rave and Sprin...
Integrating Social Apps with Content Driven Sites using Apache Rave and Sprin...Integrating Social Apps with Content Driven Sites using Apache Rave and Sprin...
Integrating Social Apps with Content Driven Sites using Apache Rave and Sprin...
 
Functional programming with_jdk8-s_ritter
Functional programming with_jdk8-s_ritterFunctional programming with_jdk8-s_ritter
Functional programming with_jdk8-s_ritter
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
 
Developing For Ubraa
Developing For UbraaDeveloping For Ubraa
Developing For Ubraa
 
Spatial approximate string search Doc
Spatial approximate string search DocSpatial approximate string search Doc
Spatial approximate string search Doc
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
 
Apouc 2014-java-8-create-the-future
Apouc 2014-java-8-create-the-futureApouc 2014-java-8-create-the-future
Apouc 2014-java-8-create-the-future
 
Mi0041 java and web design
Mi0041 java and web designMi0041 java and web design
Mi0041 java and web design
 
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
 

Último

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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
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
 

Último (20)

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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
+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...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 

Introduction to functional programming with java 8

  • 1. Copyright © 2014-2016 JavaBrahman.com Introduction to Functional Programming with Java-8 Dhruv Rai Puri JavaBrahman.com
  • 2. Copyright © 2014-2016 JavaBrahman.com HELLO! I am Dhruv Rai Puri I am a Java Architect and run the technical blog JavaBrahman.com You can reach me at dhruvraipuri@javabrahman.com Twitter~ @javabrahman facebook.com/JavaBrahman plus.google.com/+JavaBrahman
  • 3. Copyright © 2014-2016 JavaBrahman.com Whats going to be covered in this presentation › Functional Programming » What is functional programming » How it’s different from imperative programming › Important New Features in Java 8 › Functional Interfaces › Lambda Expressions
  • 4. Copyright © 2014-2016 JavaBrahman.com What is Functional Programming Focusses on WHAT is to be done Subset of Declarative Style of Programming
  • 5. Copyright © 2014-2016 JavaBrahman.com Functional V/S Imperative Programming Style of Coding Flow Control Mechanisms Order of Execution Mutability of Variables Primary Language Structures Functions as 1st Class Objects For in-depth understanding refer: http://www.javabrahman.com/programming-principles/imperative-versus-functional-programming-paradigms-conceptual/
  • 6. Copyright © 2014-2016 JavaBrahman.com New Functional Features in Java – 8 Lambda Expressions Eg:(String param)->{System.out.println("My lambda says "+param);}; Functional Interfaces Eg: @FunctionalInterface public interface Predicate<T> { boolean test(T t); } (cont…)
  • 7. Copyright © 2014-2016 JavaBrahman.com New Functional Features in Java – 8(cont…) Streams API Eg: List filteredList = employeeList.stream() .limit(2) . collect(toList()); Method References Eg: Function doubleConvertor=Double::parseDouble; Constructor Reference: <ClassName>::new For learning all new features in Java-8 refer: http://www.javabrahman.com/java-8/new-features-in-java-8/
  • 8. Copyright © 2014-2016 JavaBrahman.com Functional Interfaces › interface which has only a single abstract method 3 Types of functional interfaces public interface CustomFunctionalInterface { public void firstMethod(); } 1› Custom or User Defined (cont…)
  • 9. Copyright © 2014-2016 JavaBrahman.com Functional Interfaces(cont..) For learning in-depth about functional interfaces refer: http://www.javabrahman.com/java-8/functional-interfaces-java-8/ //java.util.function.Predicate<T> @FunctionalInterface public interface Predicate<T> { boolean test(T t); } 2› Newly defined functional interfaces in Java 8 @FunctionalInterface public interface Runnable { public abstract void run(); } 3› Pre-existing functional interfaces in Java
  • 10. Copyright © 2014-2016 JavaBrahman.com Lambda Expressions For learning in-depth about lambda expressions refer: http://www.javabrahman.com/java-8/lambda-expressions-java-8-explained-examples/ › anonymous function which can be passed around as a parameter thus achieving Behavior Parameterization @FunctionalInterface public interface FirstInterface { //the abstract method public void singleMethod(String param); } (String param)->{System.out.println("My lambda says "+param);}; Functional Interface Corresponding Lambda Expressions
  • 11. Copyright © 2014-2016 JavaBrahman.com Q & A
  • 12. Copyright © 2014-2016 JavaBrahman.com For further reading on Java-8  http://www.javabrahman.com/java-8/new-features-in-java-8/  http://www.javabrahman.com/java-8/functional-interfaces-java-8/  http://www.javabrahman.com/java-8/lambda-expressions-java-8-explained-examples/  http://www.javabrahman.com/java-8/java-8-method-references-tutorial-examples/  http://www.javabrahman.com/java-8/constructor-references-java-8-simplified-tutorial/  http://www.javabrahman.com/java-8/java-8-streams-api-tutorial-with-examples/
  • 13. Copyright © 2014-2016 JavaBrahman.com Thank You