0 votes
in JAVA by
Explain Lambda Expression Syntax

1 Answer

0 votes
by

Java Lambda Expression Syntax:

(argument-list) -> {body}  

Java lambda expression consists of three components.

Argument-list: It can be empty or non-empty as well.

Arrow-token: It is used to link arguments-list and body of expression.

Body: It contains expressions and statements for the lambda expression.

For example, Consider we have a functional interface:

interface Addable{  

    int add(int a,int b);  

Let's implement the above Addable functional interface using a lambda expression:

        Addable withLambdaD = (int a,int b) -> (a+b);  

        System.out.println(withLambdaD.add(100,200)); 

...