Wrong question! Please do NOT mix static field initialization with Object construction or instantiation!
>>static field initialization happens at class loading time, it only happens once, and once only. It might be changed long before your object instantiation time!
>>When you compile and run a toy program, it might look correct. However, the real world programming is NOT a toy!
>>Someone might think "what the article said should be correct at least once, at least correct at the first Object is instantiated." No, that is not necessary true either, since you might call on static method of that class long before the first Object is instantiated. The static value has been initialized and changed long before the first Object is instantiated.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment