System类中out属性的声明是这样的:

    public final static PrintStream out = nullPrintStream();

private static PrintStream nullPrintStream() throws NullPointerException {
if (currentTimeMillis() > 0) {
return null;
}
throw new NullPointerException();
}

问题:out并没有实例化为什么 可以 调用 PrintStream中的方法?

    原来答案在 这个方法里面:initializeSystemClass.

    这是一个用来 初始化类中静态属性的方法,至于什么 时候 初始化 ,可能是虚拟机加载 的时候 吧

    

相关文章:

  • 2021-12-09
  • 2022-01-31
  • 2021-11-30
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
  • 2022-01-03
  • 2021-10-17
猜你喜欢
  • 2022-12-23
  • 2021-11-04
  • 2021-12-09
  • 2021-12-09
相关资源
相似解决方案