Skip to main content

Lambda Expressions

Lambda Expression 

As we have seen in our last article Functional interface is introduced in Java 8 to support Lambda expression.

today we will understand lambda expression : Lambda expression implement Functional Interfaces , it save lot of code.

Check Example : WITHOUT LAMBDA EXPRESSION :




below is same example , but using lambda expression ,in this lot of code is saved as below





Lambda expression is nothing but method without name , access modifier and return type , it contain 3 main parts :

1.Parenthesis ( ) for method arguments , it can be non-empty or empty as per requirement.

2.Arrow Symbol -> indicates lambda expression  (to link method parameters or parenthesis with body).

3.Body (use curly braces for multiple lines , or if only one statement is there then curly braces are optional) 


Syntax : 

1.Syntax without method arguments :   () -> { }

1.Syntax with arguments :   (a1,a2) -> { }


Example :check one more example to understand lambda expression :


Java Lambda Expression : Filter Collection Data









Thanks For Reading