Behavior of static blocks with inheritance

后端 未结 5 888
佛祖请我去吃肉
佛祖请我去吃肉 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:01

    There is a single copy of myVar and both parent and child class will share the same. Untill and unless child class get initilized.

提交回复
热议问题