Such as:
public class innerclassdemo{
int x;
Class a{
static int a = 0;//It is illegal to write this way.
static final int b=0;//It's legal to write this
}
}
Java class load order, the class is loaded first, the static variable is initialized, and then the object is created, and if we want to execute the variable int a initialization in the code, we must first load the outer class, then load the inner class, and finally initialize the static variable A, and the problem is to load the inner class. We can think of the inner class as a non-static member of the outer class, which must be initialized after the outer class object has been created, and that the internal class must be completed after the instance is externalized, and that the Java Virtual machine requires that all static variables be completed before the object is created, which creates a contradiction.
(a bit around, hehe)
And the Java constant in the memory of the constant pool, its mechanism and variables are different, compile, load constants are not required to load the class, so there is no contradiction above.