In the code
public class Test {
public static final int var1;
public static int var2;
static {
Test.var2 = 3;
Test.var1 = Test.var2;
}
}
javac says
Test.java:8: error: cannot assign a value to final variable var1
But if I remove "Test." from "Test.var1" in the assignment, it compiles without complaint. Why does javac behave this way?