Search⌘ K

Functional Interfaces in Java

Explore functional interfaces in Java 8 to understand their single abstract method structure and role in lambda expressions. Learn about key interfaces like Predicate, Consumer, Supplier, and Function, as well as the @FunctionalInterface annotation to enforce interface contracts during compilation.

What are functional interfaces?

An interface that has a single abstract method is called a functional interface.

While an interface can have one or more default methods, it should have only one abstract method to be called a functional interface.

Java 8 has defined the ...