Java 8 Lambda Expressions: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
=Overview= | =Overview= | ||
A ''lambda'' expression can be thought of as an anonymous methods. As shown in the "[[#Syntax|Syntax]]" section below, a lambda expression looks a lot like a method declaration. | |||
=Syntax= | =Syntax= | ||
Line 26: | Line 28: | ||
The body may be a single expression, or a statement block. | The body may be a single expression, or a statement block. | ||
=Referencing a Lambda Expression= |
Revision as of 00:58, 28 November 2016
External
- Lambda Expressions Tutorial https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html
Internal
Overview
A lambda expression can be thought of as an anonymous methods. As shown in the "Syntax" section below, a lambda expression looks a lot like a method declaration.
Syntax
A lambda expression consists in a comma-separated list of formal parameters, enclosed in parentheses, followed by the arrow token "->" followed by a body, which may be a single expression or a statement block.
(comma_separated_formal_parameter_list) -> body
Formal Parameters
The type of the parameters may be omitted.
If there is a single parameter, the enclosed parentheses may be omitted.
Body
The body may be a single expression, or a statement block.