Why does the super() not showing error though not given in first line?

前端 未结 3 634
栀梦
栀梦 2021-01-29 15:14

Why does the super keyword not showing error though not given in first line

3条回答
  •  醉梦人生
    2021-01-29 15:42

    Then you might be making a method call and not Sayin super() inside constructor.. for instance..

    class Superclass
    {
    public void f1(){
    
    }
    }
    
    class Subclass extends Superclass
    {
        Subclass()
        {
            System.out.println();
            super.f1();
        }
    }
    

    The above code works fine...

提交回复
热议问题