A:inner classes can only refer to final instance variables and final methods of the enclosing class so A won't compile.
B: compiles
C,D: I have seen in Bruce Eckel's books that you can initialize a constructor from the superclass passing the variable directly (but not define a parameter here..)
E: compiles
Testing the different possibilities, I tried the following:
interface TestInterface{int i = 0;}
public class test9 {
public TestInterface getInterface3(final int i ){
return new TestInterface () {
{
System.out.println(i);
}
};
}
public static void main(
String args[]) {
test9 t = new test9();
TestInterface g = t.getInterface3(9);
}
}
this prints: 0 (instead of printing what is been given in the parameter, it prints what is in the interface). I thought that the interface value would be hidden by the parameter value, but is not like that.