In Java, is it possible to have a lambda accept multiple different types?
I.e: Single variable works:
Function adder = i
To make the use of lambda : There are three type of operation:
1. Accept parameter --> Consumer
2. Test parameter return boolean --> Predicate
3. Manipulate parameter and return value --> Function
Java Functional interface upto two parameter:
Single parameter interface
Consumer
Predicate
Function
Two parameter interface
BiConsumer
BiPredicate
BiFunction
For more than two, you have to create functional interface as follow(Consumer type):
@FunctionalInterface
public interface FiveParameterConsumer {
public void accept(T t, U u, V v, W w, X x);
}