Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Java by (10.2k points)
I'm playing with lambdas in Java 8 and I came across warning local variables referenced from a lambda expression must be final or effectively final. I know that when I use variables inside anonymous class they must be final in outer class, but still - what is the difference between final and effectively final?

1 Answer

0 votes
by (46k points)

I obtain the easiest way to describe "effectively final" is to assume adding the final modifier to a variable declaration. If with this addition, the program continues to run in the same way, both at compile time and at run time, then that variable is effectively last.

Here is the doc for your reference. 

Related questions

Browse Categories

...