In Java 8, UnaryOperator is a functional interface and it extends Function. The UnaryOperator takes one argument, and returns a result of the same type of its arguments. The Function takes one argument of any type and returns a result of any type.
In Java 8, BinaryOperator is a functional interface and it extends BiFunction. The BinaryOperator takes two arguments of the same type and returns a result of the same type of its arguments. The BiFunction takes two arguments of any type, and returns a result of any type.
In Java 8, BiConsumer is a functional interface – BiConsumer<T, U>; it takes two arguments and returns nothing. Further Reading – Java 8 Consumer Examples 1. BiConsumer JavaBiConsumer1.java Output …
In Java 8, Supplier is a functional interface; it takes no arguments and returns a result. We can use Supplier to return some values or to build factory method in initializing an object.
In Java 8, Function is a functional interface; it takes an argument (object of type T) and returns an object (object of type R). The argument and output can be a different type.
In Java 8, BiFunction is a functional interface – BiFunction
In Java 8, the double colon (::) operator is called method references. There are four kinds of method references: 1 – Reference to a static method ClassName::staticMethodName, 2 – Reference to an instance method of a particular object Object::instanceMethodName, 3 – Reference to an instance method of an arbitrary object of a particular type ContainingType::methodName, 4 – Reference to a constructor ClassName::new
In Java 8, BiPredicate is a functional interface, which accepts two arguments and returns a boolean, basically this BiPredicate is same with the Predicate, instead, it takes 2 arguments for the test.
In Java 8, Consumer is a functional interface; it takes an argument and returns nothing. It can act as Higher Order Function, so we can accepts Consumer as an argument, simulates a forEach to print each item from a list, or print the length of the string.