What are lambda expressions in Java?



The implementation of functional interfaces has simplified using lambda expressions in Java 8. The lambda expressions are functions as arguments in Java. The lambda expression introduces a new syntax element and operator in Java and refers to the lambda operator or the arrow operator (->).

Example

interface Print {
   void print(String message);
}
public class LambdaExpressionTest {
   public static void main(String args[]) {
      Print myPrint = x -> System.out.println(x);
      myPrint.print("Java Lambda Expression!");
   }
}

Output

Java Lambda Expression!

Advertisements