Statci initialize

重新开始再看一遍Thinking In Java,今天发现一点小问题.
Chapter 4

They(static variable) are initialized only when the first Table object is created (or the
first static access occurs)
其实这个描述应该不是非常的正确,比如我用Table.class,没有用到上面描述的两种情况,也会让类被加载,从而初始化静态变量,更准确地说是应该类被加载的时候初始化static的变量或者block。
结合这个贴子:http://www.iteye.com/topic/208187
里面父类合子类的初始化顺序,如果理解了"static
initialization takes place only once, as the Class object is loaded for
the first time"就能很清楚的理解原因了.- -!

你可能感兴趣的:(Access)