Behavior of static blocks with inheritance

后端 未结 5 833
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 20:13

I am trying to use static blocks like this:

I have a base class called Base.java

public class Base {

    static public int myVar;

}
         


        
5条回答
  •  無奈伤痛
    2020-12-02 21:06

    Here is the link to the Java Specification - section 8.7 talks about static initializers. It gives good details about how they should function and the order in which they get called. http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.7

提交回复
热议问题