Java lambda expressions are unnamed methods, which are used to implement the abstract method of functional interface. Lambda expressions are also known as closures. They are used to call methods as objects.
The lambda expressions are added in Java 8 and provide below functionalities.
Lambda expressions use the lambda operator (->) which divides the lambda expression into two parts. The part on the left side contains the parameters required by the lambda expression, and the part on the right side specifies the body of the lambda expression.
The parameters are enclosed in parenthesis, and the body is enclosed in curly braces.
Note: A functional interface is an interface that contains only one abstract method. A functional interface is also known as SAM(Single Abstract Method) interface. @FunctionalInterface could be written to create a functional interface that will show an error if the properties of the functional interface got violated.
#java #lambda expressions #java 8