在代码中
public class Test {
public static final int var1;
public static int var2;
static {
Test.var2 = 3;
Test.var1 = Test.var2;
}
}
javac说
Test.java:8: error: cannot assign a value to final variable var1
但如果我删除"测试。"来自" Test.var1"在任务中,它编译无怨言。为什么javac会这样做?