Why is a subclass' static initializer not invoked when a static method declared in its superclass is invoked on the subclass?

前端 未结 7 1345
南方客
南方客 2021-02-02 13:16

Given the following classes:

public abstract class Super {
    protected static Object staticVar;

    protected static void staticMethod() {
        System.out.p         


        
相关标签:
7条回答
  • 2021-02-02 14:07

    According to this article, when you call static method or use static filed of a class, only that class will be initialized.

    Here is the example screen shot.

    0 讨论(0)
提交回复
热议问题