The simple answer is, since there is no difference between final
and “effectively final” variables, besides the keyword final
in their declaration, the only purpose is to allow omitting the final
keyword.
But this might have more impact than you are aware of.
For a lambda expression, the entire declaration of the parameter(s) can be simplified as in x -> x+1
. Now consider nested lambda expressions like: x -> y -> x+y
and the visual clutter which would be created if we were enforce to add a final
declaration to the x
parameter here.
Since there is no Java syntax to declare a variable as final
without specifying its type it would either require the specification to add an even more complex construct to the language or enforce us to add final
and a type declaration to the parameter turning the simple expression x -> y -> x+y
into (final double x) -> y -> x+y
.
The main goal was to provide a simplification to the Java programmer (as far as this is possible when adding a new programming language feature). Surely it doesn’t offer any feature to the language for solving problems which couldn’t be solved before without it (this holds for the entire lambda feature), but there is a notable gain in expressiveness not only because you can omit final
modifiers but it helps. It works together with the improved type inference, new programming APIs and, of course, lambda expressions and method references.