Systematic overview of the most important functional interfaces in Java.

Photo by Michael Dziedzic, https://unsplash.com/photos/VlZYu3nZIRI

Quick links:

Runnable

The simplest functional interface, which has been around since the beginning of Java. Takes no input, and has no output.

Class Return Method Params
Runnable void run -

Suppliers

Supply output without input.

Class Return Method Params
Supplier T get -
Primitive Return
BooleanSupplier boolean getAsBoolean -
DoubleSupplier double getAsDouble -
IntSupplier int getAsInt -
LongSupplier long getAsLong -

Consumers

Consume input without output.

Class Return Method Params
Consumer void accept T
Primitive Parameter
DoubleConsumer void accept double
IntConsumer void accept int
LongConsumer void accept long
Two Parameters
BiConsumer void accept T, U
Two Parameters (One Primitive)
ObjDoubleConsumer void accept T, double
ObjIntConsumer void accept T, int
ObjLongConsumer void accept T, long

Predicates

Return a boolean depending on some input.

Class Return Method Params
Predicate boolean test T
Primitive Parameter
DoublePredicate boolean test double
IntPredicate boolean test int
LongPredicate boolean test long
Two Parameters
BiPredicate boolean test T, U

Functions

Transform input to output.

Class Return Method Params
Function R apply T
Primitive Parameter
DoubleFunction R apply double
IntFunction R apply int
LongFunction R apply long
Primitive Return
ToDoubleFunction double applyAsDouble T
ToIntFunction int applyAsInt T
ToLongFunction long applyAsLong T
Primitive Parameter and Return
DoubleToIntFunction int applyAsInt double
DoubleToLongFunction long applyAsLong double
IntToDoubleFunction double applyAsDouble int
IntToLongFunction long applyAsLong int
LongToDoubleFunction double applyAsDouble long
LongToIntFunction int applyAsInt long
Two Parameters
BiFunction R apply T, U
Two Primitive Parameters
ToDoubleBiFunction double applyAsDouble T, U
ToIntBiFunction int applyAsInt T, U
ToLongBiFunction long applyAsLong T, U

Operators

Specialized functions where input and output have the same type.

Class Return Method Params
UnaryOperator T apply T
Primitive
DoubleUnaryOperator double applyAsDouble double
IntUnaryOperator int applyAsInt int
LongUnaryOperator long applyAsLong long
Two Parameters
BinaryOperator T apply T, T
Two Primitive Parameters
DoubleBinaryOperator double applyAsDouble double, double
IntBinaryOperator int applyAsInt int, int
LongBinaryOperator long applyAsLong long, long