It's possible if you define such a functional interface with multiple type parameters. There is no such built in type. (There are a few limited types with multiple parameters.)

@FunctionalInterface
interface Function6<One, Two, Three, Four, Five, Six> {
    public Six apply(One one, Two two, Three three, Four four, Five five);
}

public static void main(String[] args) throws Exception {
    Function6<String, Integer, Double, Void, List<Float>, Character> func = (a, b, c, d, e) -> 'z';
}

I've called it Function6 here. The name is at your discretion, just try not to clash with existing names in the Java libraries.


There's also no way to define a variable number of type parameters, if that's what you were asking about.


Some languages, like Scala, define a number of built in such types, with 1, 2, 3, 4, 5, 6, etc. type parameters.

Answer from Sotirios Delimanolis on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › tutorial › java › javaOO › lambdaexpressions.html
Lambda Expressions (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
Note that a lambda expression looks a lot like a method declaration; you can consider lambda expressions as anonymous methods—methods without a name. The following example, Calculator, is an example of lambda expressions that take more than one formal parameter:
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-lambda-expressions-parameters
Java - Lambda Expressions Parameters - GeeksforGeeks
July 23, 2025 - Lambda expressions are added in Java 8. Lambda expressions express instances of functional interfaces An interface with a single abstract method is called a functional interface. One example is java.lang.Runnable. Lambda expressions implement only one abstract function and therefore implement functional interfaces. Predicate interface is an example of a functional interface that has only one abstract method called test(). ... The above is a functional interface that has one abstract method test receiving only one parameter of type T and returns a Boolean value.
🌐
TutorialsPoint
tutorialspoint.com › how-many-parameters-can-a-lambda-expression-have-in-java
How many parameters can a lambda expression have in Java?
We need to create lambda expression with multiple parameters then start the expression with parenthesis of multiple arguments. (p1,p2) -> { //Body of multiple parameter lambda } import java.util.function.*; public class LambdaExpression3 { public static void main(String args[]) { Message m ...
🌐
W3Schools
w3schools.com › java › java_lambda.asp
Java Lambda Expressions
A lambda expression can be stored in a variable. The variable's type must be an interface with exactly one method (a functional interface). The lambda must match that method's parameters and return type. Java includes many built-in functional interfaces, such as Consumer (from the java.util ...
Top answer
1 of 16
337

Lambdas are purely a call-site construct: the recipient of the lambda does not need to know that a Lambda is involved, instead it accepts an Interface with the appropriate method.

In other words, you define or use a functional interface (i.e. an interface with a single method) that accepts and returns exactly what you want.

Since Java 8 there is a set of commonly-used interface types in java.util.function.

For this specific use case there's java.util.function.IntBinaryOperator with a single int applyAsInt(int left, int right) method, so you could write your method like this:

static int method(IntBinaryOperator op){
    return op.applyAsInt(5, 10);
}

But you can just as well define your own interface and use it like this:

public interface TwoArgIntOperator {
    public int op(int a, int b);
}

//elsewhere:
static int method(TwoArgIntOperator operator) {
    return operator.op(5, 10);
}

Then call the method with a lambda as parameter:

public static void main(String[] args) {
    TwoArgIntOperator addTwoInts = (a, b) -> a + b;
    int result = method(addTwoInts);
    System.out.println("Result: " + result);
}

Using your own interface has the advantage that you can have names that more clearly indicate the intent.

2 of 16
78

To use Lambda expression you need to either create your own functional interface or use Java functional interface for operation that require two integer and return as value. IntBinaryOperator

Using user defined functional interface

interface TwoArgInterface {

    public int operation(int a, int b);
}

public class MyClass {

    public static void main(String javalatte[]) {
        // this is lambda expression
        TwoArgInterface plusOperation = (a, b) -> a + b;
        System.out.println("Sum of 10,34 : " + plusOperation.operation(10, 34));

    }
}

Using Java functional interface

import java.util.function.IntBinaryOperator;

public class MyClass1 {

    static void main(String javalatte[]) {
        // this is lambda expression
        IntBinaryOperator plusOperation = (a, b) -> a + b;
        System.out.println("Sum of 10,34 : " + plusOperation.applyAsInt(10, 34));

    }
}
🌐
W3Schools Blog
w3schools.blog › home › java 8 lambda expression multiple parameters
Java 8 lambda expression multiple parameters
April 14, 2018 - package com.w3schools; @FunctionalInterface interface AddInterface{ void add(int a, int b); } public class LambdaExpressionExample { public static void main(String args[]){ //Using lambda expressions AddInterface addInterface=(a, b)->{ System.out.println(a + b); }; addInterface.add(10, 20); } }
🌐
GeeksforGeeks
geeksforgeeks.org › java › lambda-expressions-java-8
Java Lambda Expressions - GeeksforGeeks
Java lambda expressions, introduced in Java 8, allow developers to write concise, functional-style code by representing anonymous functions. They enable passing code as parameters or assigning it to variables, resulting in cleaner and more readable ...
Published   2 weeks ago
Find elsewhere
🌐
Jenkov
jenkov.com › tutorials › java › lambda-expressions.html
Java Lambda Expressions
If the lambda expression matches ... the same interface as that parameter. Java lambda expressions can only be used where the type they are matched against is a single method interface....
🌐
Javaplanet
javaplanet.io › home › lambda expressions › lambda expressions with multiple parameters
Lambda Expressions with Multiple Parameters -
September 6, 2025 - interface Divider { String divide(int a, int b); } public class LambdaMultipleParams { public static void main(String[] args) { Divider d = (a, b) -> { if (b == 0) return "Cannot divide by zero"; return "Result: " + (a / b); }; System.out.println(d.divide(10, 2)); System.out.println(d.divide(5, 0)); } }
🌐
ScholarHat
scholarhat.com › home
Lambda Expressions in Java: Explained in Easy Steps
September 3, 2025 - ... Explanation: The correct syntax for a Lambda expression in Java includes the parameter list in parentheses, followed by the arrow (->) and the method implementation in curly braces.
🌐
Medium
medium.com › @marcelogdomingues › java-lambda-expressions-techniques-for-advanced-developersava-lambda-expressions-techniques-for-c1d71c30bb1f
Java Lambda Expressions: Techniques for Advanced Developersava Lambda Expressions: Techniques for…
June 21, 2024 - Arrow Token: The arrow token (->) separates the parameters from the body of the lambda expression. Body: The body can be a single expression or a block of statements. If the body is a single expression, the return keyword and curly braces can be omitted. ... Before lambda expressions, implementing functional interfaces required creating anonymous inner classes. This approach often led to verbose and less readable code. Example: Sorting a List Using an Anonymous Inner Class · import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; public class
🌐
CodingNomads
codingnomads.com › java-lambda-expressions
Java Lambda Expressions
Here's the syntax for creating a lambda expression in Java, where you can substitute the variables starting with your_ with your values and add as many parameters as you'd like.
🌐
Baeldung
baeldung.com › home › java › lambda expressions and functional interfaces: tips and best practices
Lambda Expressions and Functional Interfaces: Tips and Best Practices | Baeldung
December 16, 2023 - That’s why it’s safe to make our code a little bit shorter, and to exclude parentheses when there is only one parameter. ... Braces and return statements are optional in one-line lambda bodies. This means that they can be omitted for clarity and conciseness. ... Very often, even in our previous examples, lambda expressions just call methods which are already implemented elsewhere. In this situation, it is very useful to use another Java 8 feature, method references.
Top answer
1 of 6
10

In Java you need to use an array like this.

test((Object[] args) -> me.call(args));

If call takes an array variable args this will work. If not you can use reflection to make the call instead.

2 of 6
4

The final solution I currently use is defining a hierarchy of interfaces (as stated in the question) and use default methods to avoid failure. Pseudo code looks like this:

interface VarArgsRunnable {
     default void run(Object ... arguments) {
          throw new UnsupportedOperationException("not possible");
     }
     default int getNumberOfArguments() {
          throw new UnsupportedOperationException("unknown");
     }
}

and a interface for four arguments for instance:

@FunctionalInterface
interface VarArgsRunnable4 extends VarArgsRunnable {
     @Override
     default void run(Object ... arguments) {
          assert(arguments.length == 4);
          run(arguments[0], arguments[1], arguments[2], arguments[3]);
     }

     void run(Object arg0, Object arg1, Object arg2, Object arg3, Object arg4);

     @Override
     default int getNumberOfArguments() {
          return 4;
     }
}

Having defined 11 interfaces from VarArgsRunnable0 to VarArgsRunnable10 overloading a method becomes quite easy.

public void myMethod(VarArgsRunnable runnable, Object ... arguments) {
     runnable.run(arguments);
}

Since Java can not compose a Lambda by finding the correct extended functional interface of VarArgsRunnable by using something like instance.myMethod((index, value) -> doSomething(to(index), to(value)), 10, "value") one need to overload the method using the correct interface.

public void myMethod(VarArgsRunnable2 runnable, Object arg0, Object arg1) {
    myMethod((VarArgsRunnable)runnable, combine(arg0, arg1));
}

private static Object [] combine(Object ... values) {
    return values;
}

Since this requires to cast Object to any appropriated type using to(...) one can go for parameterization using Generics in order to avoid this usage.

The to-method looks like this: public static T to(Object value) { return (T)value; //Supress this warning }

The example is lame but I use it to call a method with multiple arguments being a permutation of all potential combinations (for testing purposes) like:

run((index, value) -> doTheTestSequence(index, value), values(10, 11, 12), values("A", "B", "C"));

So this little line runs 6 invocations. So you see this is a neat helper being able to test multiple stuff in a single line instead of defining a lot more or use multiple methods in TestNG and whatever... .

PS: Having no need to use reflections is quite a good thing, since it can not fail and is quite save argument count wise.

🌐
HowToDoInJava
howtodoinjava.com › home › java 8 › lambda expressions in java
Java 8 Lambda Expression (with Examples)
October 1, 2022 - Multiple parameters are enclosed in mandatory parentheses and separated by commas. Empty parentheses are used to represent an empty set of parameters. ... When there is a single parameter, if its type is inferred, it is not mandatory to use ...
🌐
Javatpoint
javatpoint.com › java-lambda-expressions
Java Lambda Expressions
October 16, 2016 - Java Lambda Expressions Tutorial with examples and topics on functional interface, anonymous class, lambda for list, lambda for comparable, lambda for runnable, lambda for single argument methods, lambda for multiple arguments methods etc.
🌐
Developer.com
developer.com › dzone › coding › languages › java lambda: method reference
Working with Lambda Expressions in Java
December 21, 2021 - Instead, it is used to implement a method defined by a function interface (this interface contains one — and only one — abstract method but also can contain multiple default and static methods).
🌐
Programiz
programiz.com › java-programming › examples › lambda-expression-as-method-parameter
Java Program to pass lambda expression as a method argument
import java.util.ArrayList; class Main { public static void main(String[] args) { // create an ArrayList ArrayList<String> languages = new ArrayList<>(); // add elements to the ArrayList languages.add("java"); languages.add("swift"); languages.add("python"); System.out.println("ArrayList: " + languages); // pass lambda expression as parameter to replaceAll() method languages.replaceAll(e -> e.toUpperCase()); System.out.println("Updated ArrayList: " + languages); } } Output ·
🌐
Readthedocs
java-8-tips.readthedocs.io › en › stable › lambdas.html
3. Lambdas — Java 8 tips 1.0 documentation
Lambda syntax follows some of the below rules. Parameter types are optional. If you have single parameter then both parameter type and parenthesis are optional. If you have multiple parameters, then they should be enclosed with in parenthesis.