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 tha
This variable below is final, so we can't change it's value once initialised. If we try to we'll get a compilation error...
final int variable = 123;
But if we create a variable like this, we can change it's value...
int variable = 123;
variable = 456;
But in Java 8, all variables are final by default. But the existence of the 2nd line in the code makes it non-final. So if we remove the 2nd line from the above code, our variable is now "effectively final"...
int variable = 123;
So.. Any variable that is assigned once and only once, is "effectively final".