Initialization of a class consists of executing its static initializers (�2.11) and the initializers for static fields (�2.9.2) declared in the class. Initialization of an interface consists of executing the initializers for fields declared in the interface (�2.13.4).
Before a class is initialized, its superclass must be initialized, but interfaces implemented by the class need not be initialized. Similarly, the superinterfaces of an interface need not be initialized before the interface is initialized.
A class or interface type T will be initialized at its first active use, which occurs if:
T is a class and a method actually declared in T (rather than inherited from a superclass) is invoked.
T is a class and a constructor for class T is invoked.
A nonconstant field declared in T (rather than inherited from a superclass or superinterface) is used or assigned. A constant field is one that is (explicitly or implicitly) both final and static, and that is initialized with the value of a compile-time constant expression. Java specifies that a reference to such a field must be resolved at compile time to a copy of the compile-time constant value, so uses of such field are never active uses.
Static initializing code is called at class load time. Then initializers for static fields are called. So even if you just declare a "der" (der myDer ; ) and defer the initialization, the static code from the base and the der are called. No instance variables are created or initialized at this point. Static methods are available to be called at this point. Note: if you say Math.sqrt(i) this causes the Math class to load.
When you declare the der the variables for a der are created on the stack
Originally posted by ryan burgdorfer:
This seems to be a contradiction...
In the last red part, did you mean to say that when you initialize the der its variables are created on the stack?