optosheng
Welcome to the
Java Ranch, we hope you’ll enjoy visiting as a regular however,
your name is not in keeping with our
naming policy here at the ranch. Please re-register under an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!
-----------------------------------
As to your question, the static variables (and static blocks) are initialized immediately after the classes direct superclass is initialized.
The
JLS section 12.4.1 says:
A class or interface type T will be initialized immediately before the first occurrence of any one of the following:
T is a class and an instance of T is created.
T is a class and a static method declared by T is invoked.
A static field declared by T is assigned.
A static field declared by T is used and the reference to the field is not a compile-time constant (�15.28). References to compile-time constants must be resolved at compile time to a copy of the compile-time constant value, so uses of such a field never cause initialization.
hope that helps
[ January 30, 2002: Message edited by: Dave Vick ]