Thursday 18 August 2016

Java 8 : Lambda Expression

Lambda Expression is one of the best feature given by Java 8.
It is used for functional programming.

Syntax :

parameter - > expression body

Note :
1) Optional Parenthesis : for the parameter if its single parameter. For multiple parameters you need to specify the the parenthesis.
2) Optional type declaration : type of the parameter need not be specified. The value that is returned by the function will take care of the parameter type.
3) Optional curly braces
4) Optional return type if the body has single expression of return type.

No comments: