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

后端 未结 12 932
無奈伤痛
無奈伤痛 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:13

    Just call it using super.

    public void myMethod()
    {
        // B stuff
        super.myMethod();
        // B stuff
    }
    

提交回复
热议问题