In Java, how do I call a base class's method from the overriding method in a derived class?

后端 未结 12 909
無奈伤痛
無奈伤痛 2020-11-27 02:50

I have two Java classes: B, which extends another class A, as follows :

class A {
    public void myMethod() { /* ... */ }
}

class B extends A {
    public          


        
12条回答
  •  春和景丽
    2020-11-27 03:08

    See, here you are overriding one of the method of the base class hence if you like to call base class method from inherited class then you have to use super keyword in the same method of the inherited class.

提交回复
热议问题