Any local variable used but not declared in an inner class must be declared final.
Mentioned here
I compiled this code without using the final keyword , still works . But in section 8.1.3 they have specified that we need to use final.
Did this use to be the case in “older days” ? If so , what was the motivation behind this?
class Outer {
static void classMethod() {
final int l = 200; // do we need final here?
class LocalInStaticContext {
int m = l; // OK
}
}
}
6