1 / 13

Introduction to Functional Programming with Java-8

Introduction to Functional Programming with Java-8. Dhruv Rai Puri JavaBrahman.com. HELLO!. I am Dhruv Rai Puri. I am a Java Architect and run the technical blog JavaBrahman.com. dhruvraipuri@javabrahman.com T witter~ @javabrahman facebook.com/JavaBrahman plus.google.com/+JavaBrahman.

gmock
Download Presentation

Introduction to Functional Programming with Java-8

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Functional Programming with Java-8 Dhruv Rai Puri JavaBrahman.com

  2. HELLO! I am Dhruv Rai Puri I am a Java Architect and run the technical blog JavaBrahman.com • dhruvraipuri@javabrahman.com • Twitter~ @javabrahman • facebook.com/JavaBrahman • plus.google.com/+JavaBrahman • You can reach me at

  3. 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. What is Functional Programming Focusses on WHAT is to be done Subset of Declarative Style of Programming

  5. Functional V/S Imperative Programming Style of Coding Mutability of Variables Order of Execution Functions as 1st Class Objects Primary Language Structures Flow Control Mechanisms For in-depth understanding refer: http://www.javabrahman.com/programming-principles/imperative-versus-functional-programming-paradigms-conceptual/

  6. New Functional Features in Java – 8 Functional Interfaces Eg: @FunctionalInterface public interface Predicate<T> { boolean test(T t); } Lambda Expressions Eg:(String param)->{System.out.println("My lambda says "+param);}; (cont…)

  7. New Functional Features in Java – 8(cont…) Method References • Eg: Function doubleConvertor=Double::parseDouble; • Constructor Reference: <ClassName>::new Streams API Eg: List filteredList = employeeList.stream() .limit(2) . collect(toList()); For learning all new features in Java-8 refer: http://www.javabrahman.com/java-8/new-features-in-java-8/

  8. Functional Interfaces › interface which has only a single abstract method 3 Types of functional interfaces 1› Custom or User Defined public interface CustomFunctionalInterface { public void firstMethod(); } (cont…)

  9. Functional Interfaces(cont..) 2› Newly defined functional interfaces in Java 8 //java.util.function.Predicate<T> @FunctionalInterface public interface Predicate<T> { boolean test(T t); } 3› Pre-existing functional interfaces in Java @FunctionalInterface public interface Runnable { public abstract void run(); } For learning in-depth about functional interfaces refer: • http://www.javabrahman.com/java-8/functional-interfaces-java-8/

  10. Lambda Expressions › anonymous function which can be passed around as a parameter thus achieving Behavior Parameterization Functional Interface @FunctionalInterface public interface FirstInterface { //the abstract method public void singleMethod(String param); } Corresponding Lambda Expressions (String param)->{System.out.println("My lambda says "+param);}; For learning in-depth about lambda expressions refer: • http://www.javabrahman.com/java-8/lambda-expressions-java-8-explained-examples/

  11. Q & A

  12. 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. Thank You

More Related