SlideShare a Scribd company logo
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 (20)

Lambdas
LambdasLambdas
Lambdas
malliksunkara
 
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
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)
Java 8 Streams And Common Operations By Harmeet Singh(Taara)
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
Syed Awais Mazhar Bukhari
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
Oleg Tsal-Tsalko
 
Functional programming with Xtend
Functional programming with XtendFunctional programming with Xtend
Functional programming with Xtend
Sven 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 Overview
Eclipse Day India
 
Xtend - better java with -less- noise
Xtend - better java with -less- noiseXtend - better java with -less- noise
Xtend - better java with -less- noise
Neeraj Bhusare
 
Xtext Webinar
Xtext WebinarXtext Webinar
Xtext Webinar
Heiko Behrens
 
Introduction to functional programming, with Elixir
Introduction to functional programming,  with ElixirIntroduction to functional programming,  with Elixir
Introduction to functional programming, with Elixir
kirandanduprolu
 
JavaScript Introductin to Functions
JavaScript Introductin to FunctionsJavaScript Introductin to Functions
JavaScript Introductin to Functions
Charles 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 ugly
Bozhidar Bozhanov
 
PHP 5
PHP 5PHP 5
PHP 5
Rafael Corral
 
Learn To Code: Introduction to c
Learn To Code: Introduction to cLearn To Code: Introduction to c
Learn To Code: Introduction to c
SadhanaParameswaran
 
Functional programming
Functional programmingFunctional programming
Functional programming
PiumiPerera7
 
Plpgsql russia-pgconf
Plpgsql russia-pgconfPlpgsql russia-pgconf
Plpgsql russia-pgconf
Pavel Stěhule
 
Intro to java 8
Intro to java 8Intro to java 8
Intro to java 8
John Godoi
 
Web programming
Web programmingWeb programming
Web programming
Leo Mark Villar
 
Java 8
Java 8Java 8
Java 8
Sudipta K Paik
 
Functional Programming in Java
Functional Programming in JavaFunctional Programming in Java
Functional Programming in Java
Narendran Solai Sridharan
 
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
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)
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 Xtend
Sven 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 Overview
Eclipse Day India
 
Xtend - better java with -less- noise
Xtend - better java with -less- noiseXtend - better java with -less- noise
Xtend - better java with -less- noise
Neeraj Bhusare
 
Introduction to functional programming, with Elixir
Introduction to functional programming,  with ElixirIntroduction to functional programming,  with Elixir
Introduction to functional programming, with Elixir
kirandanduprolu
 
JavaScript Introductin to Functions
JavaScript Introductin to FunctionsJavaScript Introductin to Functions
JavaScript Introductin to Functions
Charles 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 ugly
Bozhidar Bozhanov
 
Learn To Code: Introduction to c
Learn To Code: Introduction to cLearn To Code: Introduction to c
Learn To Code: Introduction to c
SadhanaParameswaran
 
Functional programming
Functional programmingFunctional programming
Functional programming
PiumiPerera7
 
Intro to java 8
Intro to java 8Intro to java 8
Intro to java 8
John Godoi
 

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

Lambdas, Collections Framework, Stream API
Lambdas, Collections Framework, Stream APILambdas, Collections Framework, Stream API
Lambdas, Collections Framework, Stream API
Prabu U
 
Functional programming
Functional programmingFunctional programming
Functional programming
Lhouceine OUHAMZA
 
Lambdas in Java 8
Lambdas in Java 8Lambdas in Java 8
Lambdas in Java 8
Tobias Coetzee
 
Java 8 new features
Java 8 new featuresJava 8 new features
Java 8 new features
Aniket Thakur
 
Functional Programming in Java
Functional Programming in JavaFunctional Programming in Java
Functional Programming in Java
Jim Bethancourt
 
Week-1..................................
Week-1..................................Week-1..................................
Week-1..................................
kmjanani05
 
Fun with java 8
Fun with java 8Fun with java 8
Fun with java 8
Victor Perepelitsky
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8
icarter09
 
Lambdas : Beyond The Basics
Lambdas : Beyond The BasicsLambdas : Beyond The Basics
Lambdas : Beyond The Basics
Simon Ritter
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
NexThoughts Technologies
 
Java8
Java8Java8
Java8
Freeman Zhang
 
Functional Programming In Java Harnessing The Power Of Java 8 Lambda Expressi...
Functional Programming In Java Harnessing The Power Of Java 8 Lambda Expressi...Functional Programming In Java Harnessing The Power Of Java 8 Lambda Expressi...
Functional Programming In Java Harnessing The Power Of Java 8 Lambda Expressi...
coriehokitiw
 
Java 8 - functional features
Java 8 - functional featuresJava 8 - functional features
Java 8 - functional features
Rafal Rybacki
 
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
Simon Ritter
 
Java8
Java8Java8
Java8
Sunil Kumar
 
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
IndicThreads
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8
Bansilal Haudakari
 
Java 8 Functional Programming - I
Java 8 Functional Programming - IJava 8 Functional Programming - I
Java 8 Functional Programming - I
Ugur Yeter
 
Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An Overview
Indrajit Das
 
Java 8 lambda
Java 8 lambdaJava 8 lambda
Java 8 lambda
Manav Prasad
 
Lambdas, Collections Framework, Stream API
Lambdas, Collections Framework, Stream APILambdas, Collections Framework, Stream API
Lambdas, Collections Framework, Stream API
Prabu U
 
Functional Programming in Java
Functional Programming in JavaFunctional Programming in Java
Functional Programming in Java
Jim Bethancourt
 
Week-1..................................
Week-1..................................Week-1..................................
Week-1..................................
kmjanani05
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8
icarter09
 
Lambdas : Beyond The Basics
Lambdas : Beyond The BasicsLambdas : Beyond The Basics
Lambdas : Beyond The Basics
Simon Ritter
 
Functional Programming In Java Harnessing The Power Of Java 8 Lambda Expressi...
Functional Programming In Java Harnessing The Power Of Java 8 Lambda Expressi...Functional Programming In Java Harnessing The Power Of Java 8 Lambda Expressi...
Functional Programming In Java Harnessing The Power Of Java 8 Lambda Expressi...
coriehokitiw
 
Java 8 - functional features
Java 8 - functional featuresJava 8 - functional features
Java 8 - functional features
Rafal Rybacki
 
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
Simon Ritter
 
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
IndicThreads
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8
Bansilal Haudakari
 
Java 8 Functional Programming - I
Java 8 Functional Programming - IJava 8 Functional Programming - I
Java 8 Functional Programming - I
Ugur Yeter
 
Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An Overview
Indrajit Das
 
Ad

Recently uploaded (20)

cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Cisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdfCisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdf
superdpz
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Cisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdfCisco ISE Performance, Scalability and Best Practices.pdf
Cisco ISE Performance, Scalability and Best Practices.pdf
superdpz
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Ad

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 [email protected] 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