Course contentsShow
← Java
Lesson 1631 of 2,87035. Functional InterfacesFree lesson

Functional Interfaces vs Regular Interfaces

Key differences between functional interfaces and traditional interfaces with multiple abstract methods.

Functional Interfaces vs Regular Interfaces

What you'll learn: You'll understand the key differences between functional interfaces and traditional interfaces with multiple abstract methods.

The Core Distinction

A functional interface follows the Single Abstract Method (SAM) rule—it contains exactly one abstract method (though it may include default methods, static methods, and methods inherited from Object). A regular interface, by contrast, can have any number of abstract methods, from zero to many.

Think of it like a contract: a functional interface is a specialized, minimal contract designed for a single operation, while a regular interface can describe a complex set of behaviors.

Key Differences

Abstract Method Count

  • Functional Interface: Exactly 1 abstract method
  • Regular Interface: 0, 1, 2, or more abstract methods

Lambda Compatibility

  • Functional Interface: Can be implemented using lambda expressions, method references, or constructor references
  • Regular Interface: Requires explicit class implementations or anonymous classes

Purpose and Design

  • Functional Interface: Designed to represent behavior that can be passed around (like strategies or callbacks)
  • Regular Interface: Designed to define type contracts with multiple behaviors

The @FunctionalInterface Annotation

  • Functional Interface: Optionally marked with @FunctionalInterface for compile-time verification
  • Regular Interface: Cannot use this annotation (compiler will reject it if multiple abstract methods exist)

Why It Matters

Functional interfaces enable the functional programming features in Java—they're the bridge that makes lambdas possible. A regular interface like Comparator from older Java versions could become a functional interface if it happens to have exactly one abstract method, which is why Comparator<T> works with lambdas today.

Key Takeaway: Functional interfaces are specialized interfaces with exactly one abstract method that enable lambda expressions, while regular interfaces can define any number of abstract methods but require traditional implementation approaches.