Skip to content


JSR335: Lambda Expressions

August 13, 2013

Lambda expressions

Lambda expressions are similar to methods: it provides a list of formal parameters and a body. Lambda expression parameter type can either be declared explicitly or inferred from the functional interface the lambda is being targeted.

this and super in a lambda expression is only allowed if it’s allowed in the surrounding context, and therefore the this/super in the lambda express refers to the surrounding object, not to any anonymous class instance.

Lambda blocks that don’t return anything are void compatible, while lambdas that do return something are value compatible.

Effectively final

A local variable or a method, constructor, lambda, or exception parameter is effectively final if it is not final but it never occurs as the left hand operand of an assignment operator or as the operand of an increment or decrement operator.

Effectively final was added to Lambdas and also inner classes.

Throws clauses defined on a lambda expression must be handled by an enclosing try block, just as it would for a method call with a throws clause.

Multi-catch exception parameters are implicitly final, but not effectively final.

Code Examples

These are mostly from the JLS 8, but 1 is a simple example ( of how to call a lambda expression.



From → Java

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: