Breeze
发贴: 143
积分: 30
|
于 2003-01-22 22:51
snowbug wrote: The order of the class initialization: 1. static variables and static blocks, based on the order they appear in the class (this only happens at the first time the class is accessed) 2. the non-static variables 3. constructor
The above steps (1 through 3) are repeated top-down in the class inheritance tree. For example, if class A is the sub-class of B and B is the sub-class of the root class Object, then the following initialization will occur when you call A a = new A();: i) do step 1 through 3 for the root class Object ii) do step 1 through 3 for class B iii) do step 1 through 3 for class A
这个说法应该是错误的。 具体应该是这样的: 1、root->B->A,执行step 1. 2、root执行step 2,step3 3、B执行step 2,step 3 4、A执行step 2,step 3.
|