On Java 1.8, you don't have to define a field as final
to it be acessed from anonymous classes.
For example, on older versions:
public void foo(final int bar) {
new Runnable() {
public void run() {
System.out.println(bar);
}
};
}
But, now, on Java 1.8, bar
does not need to be final:
public void foo(int bar) {
new Runnable() {
public void run() {
System.out.println(bar);
}
};
}
So, if I compile my project, and the only resource implemented on Java 1.8 I'm using is this (I'm not using any lambdas, new classes, etc), will my code be executable on computers with older Java versions? If not, why?