Lambda expressions are only usable with functional interface as said by Eran but if you really need multiple methods within the interfaces, you may change the modifiers to default or static and override them within the classes that implement them if necessary.

public class Test {
    public static void main(String[] args) {
        I1 i1 = () -> System.out.println(); // NOT LEGAL
        I2 i2 = () -> System.out.println(); // TOTALLY LEGAL
        I3 i3 = () -> System.out.println(); // TOTALLY LEGAL
    }
}

interface I1 {
    void show1();
    void show2();
}

interface I2 {
    void show1();
    default void show2() {}
}

interface I3 {
    void show1();
    static void show2 () {}
}

Inheritance

You shouldn't forget the inherited methods.

Here, I2 inherits show1 and show2 and thus can not be a functional interface.

public class Test {
    public static void main(String[] args) {
        I1 i1 = () -> System.out.println(); // NOT LEGAL BUT WE SAW IT EARLIER
        I2 i2 = () -> System.out.println(); // NOT LEGAL
    }
}

interface I1 {
    void show1();
    void show2();
}

interface I2 extends I1 {
    void show3();
}

Annotation

To make sure your interface is a functional interface, you may add the following annotation @FunctionalInterface

@FunctionalInterface <------- COMPILATION ERROR : Invalid '@FunctionalInterface' annotation; I1 is not a functional interface
interface I1 {
    void show1();
    void show2();
}

@FunctionalInterface
interface I2 {
    void show3();
}
Answer from Yassin Hajaj on Stack Overflow
Top answer
1 of 4
37

Lambda expressions are only usable with functional interface as said by Eran but if you really need multiple methods within the interfaces, you may change the modifiers to default or static and override them within the classes that implement them if necessary.

public class Test {
    public static void main(String[] args) {
        I1 i1 = () -> System.out.println(); // NOT LEGAL
        I2 i2 = () -> System.out.println(); // TOTALLY LEGAL
        I3 i3 = () -> System.out.println(); // TOTALLY LEGAL
    }
}

interface I1 {
    void show1();
    void show2();
}

interface I2 {
    void show1();
    default void show2() {}
}

interface I3 {
    void show1();
    static void show2 () {}
}

Inheritance

You shouldn't forget the inherited methods.

Here, I2 inherits show1 and show2 and thus can not be a functional interface.

public class Test {
    public static void main(String[] args) {
        I1 i1 = () -> System.out.println(); // NOT LEGAL BUT WE SAW IT EARLIER
        I2 i2 = () -> System.out.println(); // NOT LEGAL
    }
}

interface I1 {
    void show1();
    void show2();
}

interface I2 extends I1 {
    void show3();
}

Annotation

To make sure your interface is a functional interface, you may add the following annotation @FunctionalInterface

@FunctionalInterface <------- COMPILATION ERROR : Invalid '@FunctionalInterface' annotation; I1 is not a functional interface
interface I1 {
    void show1();
    void show2();
}

@FunctionalInterface
interface I2 {
    void show3();
}
2 of 4
14

Lambda expressions can only be used to implement functional interfaces, which are interfaces having a single abstract method. An interface with two abstract methods can't be implemented by a lambda expression.

🌐
Sunflower Lab
thesunflowerlab.com › home › java lambda expressions
Java Lambda Expression - How To Implement Functional Interface
September 4, 2024 - It is used for implementing the functional interface. An Interface with only one abstract method is called a functional interface. A “@FunctionalInterface” annotation is used to indicate a functional interface.
🌐
DZone
dzone.com › coding › java › functional interface and lambda expressions in java 8
Functional Interface and Lambda Expressions in Java 8
July 23, 2018 - Lambda expressions are introduced in Java 8, and they can represent the instance of a functional interface. To explain the above statement, we are defining a functional interface named "SquareRoot." It has only one abstract method, "findSquareRoot." @FunctionalInterface annotations are used to declare an interface as a functional interface.
🌐
Stack Abuse
stackabuse.com › guide-to-functional-interfaces-and-lambda-expressions-in-java
Guide to Functional Interfaces and Lambda Expressions in Java
March 29, 2023 - StringConcat is an interface and can not be instantiated. On the right-hand side of the assignment, the compiler expects to find an instantiation of a class that implements StringConcat, not a function. Yet, the code works seamlessly. Java is inherently object-oriented. Everything is an object in Java (more accurately, everything extends into an Object class), including lambda expressions.
🌐
Medium
medium.com › @lakshyachampion › mastering-functional-interfaces-and-lambda-expressions-in-java-c02d8aaff5b2
Mastering Functional Interfaces and Lambda Expressions in Java | by Lakshya Agarwal | Medium
January 17, 2024 - To employ this type of lambda expression, an interface with a single abstract method that takes no input and provides no output is required. Instead of manually creating such an interface, Java provides default functional interfaces.
🌐
GeeksforGeeks
geeksforgeeks.org › java › match-lambdas-to-interfaces-in-java
Match Lambdas to Interfaces in Java - GeeksforGeeks
July 23, 2025 - Lambda expression only works with functional interfaces in java. Lambda expression provides a clear and concise way to represent a method interface via an expression. It provides the implementation of a functional interface and simplifies software ...
🌐
Jenkov
jenkov.com › tutorials › java-functional-programming › functional-interfaces.html
Java Functional Interfaces
March 8, 2021 - A Java functional interface can be implemented by a Java Lambda Expression.
🌐
SWTestAcademy
swtestacademy.com › home › lambda functions in java and custom functional interfaces
Lambda Functions in Java and Custom Functional Interfaces
October 10, 2021 - It is good to learn lambda declarations with custom functional interfaces together. Let’s create a custom interface as PlayMusicService which has a single abstract run method. //SAM: Single Abstract Method (Functional Interface annotation dictates that this interface has single abstract method.) @FunctionalInterface public interface PlayMusicService { void run(String song); } Now, let’s implement this run method in a test class in two ways, the classical way with @override annotation and the more modern way with a lambda function declaration.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › how-can-we-use-lambda-expressions-with-functional-interfaces-in-java
How can we use lambda expressions with functional interfaces in Java?
July 10, 2020 - @FunctionalInterface interface BonusCalculator { public double calcBonus(int amount); } class EmpDetails { public void getBonus(BonusCalculator calculator, int amount) { double bonus = calculator.calcBonus(amount); System.out.println("Bonus: " + bonus); } } public class LambdaExpressionTest { public static void main(String[] args) { EmpDetails details = new EmpDetails(); //Using Anonymous inner class EmpDetails details = new EmpDetails(); details.getBonus(new BonusCalculator () { public double calcBonus(int amount) { System.out.println("Bonus Calculation of an Employee using Ananymous inner class"); return amount*2; } },2000); // using Lambda Expression details.getBonus((amount) -> { System.out.println("Bonus Calculation of an Employee using Lambda Expression"); return amount*2; },2000); } }
🌐
Nachoiborraies
nachoiborraies.github.io › java › md › en › 11b.html
Functional programming | Java programming language
Since Java 8, lambda expressions, also called anonymous functions in many languages, are an easy and fast way to implement an interface method without having to create a new class for doing that.
🌐
Oracle
oracle.com › java › technical details
Trying Out Lambda Expressions in the Eclipse IDE - Java
In this section, we will discuss how some common functional interfaces can be used with lambda expressions. The FileFilter interface has a single method,accept(), and is used to filter files. In The Java Tutorials ImageFilter example, the ImageFilter class implements the FileFilter interface and provides implementation for the accept() method.
🌐
Medium
medium.com › @gauravverma.career › functional-interface-and-lambda-expression-34e9b678be20
Functional interface and Lambda expression | by Gaurav Verma | Medium
December 7, 2025 - Introduced in Java 8, Functional Interfaces provide a clear and concise way to implement behaviour using lambda expressions. Before diving into functional interfaces, it’s helpful to understand the concept of anonymous classes, as they share a similar usage pattern. A Functional Interface is an interface that contains exactly one abstract method, though it can include any number of default or static methods. /*interface with only one abstract method * This is a functional interface * */ @java.lang.FunctionalInterface interface MyInterface { void printSomething(); }
🌐
JavaGoal
javagoal.com › home › why lambda expression use functional interface only
Lambda Expression Use Functional Interface in Java
July 15, 2022 - So, let’s add another abstract method to the interface and try to implement it with Lambda expression. public interface Display { public void show(); public void data(); } public class ExampleWithLambda { public static void main(String[] args) { Display display = () -> { System.out.println("In ...
🌐
Rice
clear.rice.edu › comp310 › JavaResources › lambdas.html
Lambda Functions
Java, starting with Java 8, introduced ... their implementation). One can think of Java's lambda implementation as a shortcut syntax for anonymous inner classes that implement interfaces with a single method....
🌐
FavTutor
favtutor.com › blogs › lambda-expressions-java
Lambda Expression in Java 8: Example, Advantages & Code
December 12, 2022 - To declare an interface as a functional interface, Java provides an annotation @FunctionalInterface. They are anonymous or unnamed method that does not execute on their own. They are like functions that take arguments and do some functionality ...
🌐
Oracle
docs.oracle.com › javase › tutorial › java › javaOO › lambdaexpressions.html
Lambda Expressions (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
You can specify this action with a lambda expression. Suppose you want a lambda expression similar to printPerson, one that takes one argument (an object of type Person) and returns void. Remember, to use a lambda expression, you need to implement a functional interface.
🌐
KoderHQ
koderhq.com › tutorial › java › lambda
Java Lambda Expressions Tutorial | KoderHQ
In the example above we add another interface that will format some text with html tags to be used in an html document. The ‘format’ lambda has more than one statement in its body, so we must return a value explicitly. A lambda expression is a method without a name, and doesn’t require a class. Lambda’s implement methods from functional interfaces.
🌐
Medium
amanagrawal9999.medium.com › internal-working-of-functional-interface-and-lambda-expression-d6a19e5d2f46
Internal working of the functional interface and lambda expression | by Aman Agrawal | Medium
October 17, 2020 - A lambda expression is an anonymous method that is used to implement the abstract method of the functional interface. It has three parts — First is the parameter list then the arrow (->) which is the new operator introduced in Java 8 and then ...
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-implement-the-runnable-interface-using-lambda-expression-in-java
How to implement the Runnable interface using lambda expression in Java?
July 13, 2020 - public class RunnableLambdaTest { public static void main(String[] args) { Runnable r1 = new Runnable() { @Override public void run() { // anonymous class System.out.println("Runnable with Anonymous Class"); } }; Runnable r2 = () -> { // lambda expression System.out.println("Runnable with Lambda Expression"); }; new Thread(r1).start(); new Thread(r2).start(); } } Runnable with Anonymous Class Runnable with Lambda Expression<strong> </strong>
🌐
Medium
shiharadilshan.medium.com › java-lambda-expressions-and-functional-interfaces-c6ac060e19d9
Java Lambda expressions and Functional interfaces. | by Shihara Dilshan | Medium
July 28, 2023 - Functional interface is just a interface in java but only have 1 abstract method. Interfaces can have many abstract methods but in functional interface there is only one. How a functional interface is different than a normal interface? The main difference is you can you Lambda to instantiate a functional interface. That means you don’t need a concrete class to implement the functional interface.