SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

What's hot (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 to Introduction to functional programming with java 8

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
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
Nayden Gochev
 

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

Recently uploaded

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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
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...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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
 
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 Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
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...
 

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