What are some of the predefined functional interfaces in Java 8?

Java 8's java.util.function package ships a set of general-purpose functional interfaces covering the most common shapes of behavior, so developers rarely need to define their own for everyday tasks.

Key Points

Example

Function<String, Integer> toLength = String::length; captures the idea of turning a String into an Integer, and can be passed directly to Stream.map() on a stream of strings.

Function<String, Integer> toLength = String::length;
Consumer<String> printer = System.out::println;
Supplier<String> greeting = () -> "Hello";
Predicate<String> isEmpty = String::isEmpty;

System.out.println(toLength.apply("Java")); // 4

Interview Tip

A concise interview answer is

The core ones are Function for a one-argument transformation, Consumer for a one-argument action with no return value, Supplier for producing a value with no input, and Predicate for a one-argument boolean test. There are also two-argument variants like BiFunction, and primitive versions like IntFunction to avoid boxing — together they cover almost every shape of lambda you'd write.

Last updated: 16 July 2026

Previous question: What is a functional interface in Java 8?

Next question: What is the Streams API in Java 8? How does it work?

More Java 8 interview questions

All Java 8 questions