I have simple class that contains inner class that according to my understanding uses effectively final variable f
:
public class WithInner {
public static void main (String [] args)
{
WithInner i = new WithInner();
}
interface LocalInterface
{
void iia();
}
public void aa()
{
int f = 20;
LocalInterface i = new LocalInterface() {
public void iia() {
System.out.println(" "+f);
}
};
}
}
But my Intellij
IDE complains regarding f is not declared final:
local variable
f
is accessed from within inner class; needs to be declaredfinal
But if the f
variable is effectively final there is no need to declare it final
, isn't that true?
UPD:
My project structure is configured to use Java 8: