Selenium Automation

Lambda expressions in Java

Lambda expressions is a new feature introduced in Java 8. Lambda expressions are used to create instances (‘Instance’ is creation of object) of functional interfaces. A functional interface is basically an interface with single abstract method( For example Runnable, callable, ActionListener etc).A lambda expression can be expressed as an anonymous function that doesn’t have a name and doesn’t belong to any class. The concept of lambda expression was first introduced in LISP programming language.

Lambda expression syntax:

To create a lambda expression we specify input parameters (if there are any) on the left side of the lambda operator “ ->” and place the expression or block of statements on the right side of the lambda operator.

Notes:

1.The lambda expressions can be used with the existing API even when your project is migrated to Java 8.
2.The code is compressed to few lines with lambda expression.
3.Easy implementation of functional interface with the lambda operator.