0 votes
25 views

What are the characteristics of a Java 8 lambda expression?

in Education by (51.6k points)

1 Answer

0 votes

What are the characteristics of a Java 8 lambda expression in Java8?

A lambda expression is characterized by the following syntax -

parameter -> expression body

Following are the important characteristics of a lambda expression -

Optional type declaration - No need to declare the type of a parameter. The compiler can inference the same from the value of the parameter.

Optional parenthesis around parameter - No need to declare a single parameter in parenthesis. For multiple parameters, parentheses are required.

Optional curly braces - No need to use curly braces in expression body if the body contains a single statement.

Optional return keyword - The compiler automatically returns the value if the body has a single expression to return the value. Curly braces are required to indicate that expression returns a value.

by (51.6k points)

Related questions

0 votes
1 answer 13 views
0 votes
1 answer 11 views
0 votes
1 answer 14 views
0 votes
1 answer 13 views
0 votes
1 answer 50 views
0 votes
1 answer 14 views
0 votes
1 answer 34 views
0 votes
1 answer 14 views
0 votes
1 answer 26 views
0 votes
1 answer 13 views
0 votes
1 answer 14 views
14 views asked Nov 8, 2020 in Education by Editorial Staff (51.6k points)
0 votes
1 answer 17 views
0 votes
1 answer 19 views
0 votes
1 answer 11 views
11 views asked Nov 8, 2020 in Education by Editorial Staff (51.6k points)
0 votes
1 answer 11 views
0 votes
1 answer 13 views
0 votes
1 answer 15 views
0 votes
1 answer 22 views
0 votes
1 answer 8 views
0 votes
1 answer 18 views
0 votes
1 answer 16 views
0 votes
1 answer 13 views
13 views asked Nov 8, 2020 in Education by Editorial Staff (51.6k points)
...