functional interface
Last updated
Was this helpful?
Last updated
Was this helpful?
A functional interface in Java is an interface that contains only one single abstract(unimplemented) method. A functional interface can contain default and static methods which do have an implementation, in addition to the single unimplemented method.
Java contains a set of functional interfaces designed for commonly occuring use cases.
The Java Predicate
interface, java.util.function.Predicate
, represents a simple function that takes a single value as parameter, and returns true or false.
eg:
that represents a function that supplies a value of some sorts. The Supplier interface can also be thought of as a factory interface.
It does not take any arguments.
eg:
that consumes a value without returning any value. A Java Consumer implementation could be printing out a value, or writing it to a file, or over the network etc.
eg: