Содержание
- 2. Agenda Functional Interface Lambda Expression Built-in Functional Interfaces in Java Function Predicate UnaryOperator BinaryOperator Supplier Consumer
- 3. Functional Interfaces A functional interface in Java is an interface that contains only a single abstract
- 4. Functional Interfaces Normally a Java interface does not contain implementations of the methods it declares. But
- 5. @FunctionalInterface Annotation @FunctionalInterface annotation is used to ensure that the functional interface can’t have more than
- 6. Lambda expressions lambda expressions are added in Java 8 and provide below functionalities. Enable to treat
- 7. Syntax of lambdas where lambda operator can be: Zero parameter: One parameter:– It is not mandatory
- 8. Lambda Expression A Java functional interface can be implemented by a Java Lambda Expression. A Java
- 9. Built-in Functional Interfaces in Java
- 10. Function The Function interface (java.util.function.Function) represents a function (method) that takes a single parameter and returns
- 11. Function The only method you have to implement to implement the Function interface is the apply()
- 12. Function An example of using the above AddThree class: First this example creates a new AddThree
- 13. Function You can also implement the Function interface using a Java lambda expression: The Function interface
- 14. Predicate The Java Predicate interface (java.util.function.Predicate) represents a simple function that takes a single value as
- 15. Predicate You can implement the Predicate interface using a class, like this: The Predicate interface contains
- 16. Predicate You can also implement the Java Predicate interface using a Lambda expression. Here is an
- 17. UnaryOperator The Java UnaryOperator interface is a functional interface that represents an operation which takes a
- 18. BinaryOperator The Java BinaryOperator interface is a functional interface that represents an operation which takes two
- 19. Supplier The Java Supplier interface is a functional interface that represents an function that supplies a
- 20. Consumer The Java Consumer interface is a functional interface that represents an function that consumes a
- 21. Method Reference Method reference is used to refer a method without invoking it. Instead of providing
- 22. References http://tutorials.jenkov.com/java-functional-programming/functional-interfaces.html https://metanit.com/java/tutorial/3.16.php https://metanit.com/java/tutorial/9.1.php
- 24. Скачать презентацию