刚在看虚拟机相关知识点 看到一段代码,大家猜测一下这段代码会触发子类初始化吗

public class SuperClass{

    static{
      system.out.println("SuperClass init.");
    }    
    public static int value=1233;

}

public class SubClass{
      static{
        system.out.println("Subclass init.");
    
      }
}


public class NotInitDemo{

    public void main(String[] args){
     system.out.println(SubClass.value);

    }

}

实际输出是  SuperClass init.

没有输出子类内容 为什么呢 ?

 ...未完待续

相关文章:

  • 2023-03-18
  • 2021-09-28
  • 2022-12-23
  • 2023-03-20
  • 2022-12-23
  • 2022-12-23
  • 2022-03-01
  • 2022-01-16
猜你喜欢
  • 2022-12-23
  • 2021-11-23
  • 2022-02-28
  • 2021-04-21
  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
相关资源
相似解决方案