February 2014
Beginner
1248 pages
62h 25m
English
• A lambda expression (p. 733) represents an anonymous method—a shorthand notation for implementing a functional interface.
• The type of a lambda is the type of the functional interface that the lambda implements.
• Lambda expressions can be used anywhere functional interfaces are expected.
• A lambda consists of a parameter list followed by the arrow token (->, p. 733) and a body, as in:
(parameterList) -> {statements}
For example, the following lambda receives two ints and returns their sum:
(int x, int y) -> {return x + y;}
This lambda’s body is a statement block that may contain one or more statements enclosed in curly braces.
• A lambda’s parameter ...
Read now
Unlock full access