I have two Java classes: B, which extends another class A, as follows :
class A {
public void myMethod() { /* ... */ }
}
class B extends A {
public
Just call it using super.
public void myMethod()
{
// B stuff
super.myMethod();
// B stuff
}
super.MyMethod()
should be called inside the MyMethod()
of the class B
. So it should be as follows
class A {
public void myMethod() { /* ... */ }
}
class B extends A {
public void myMethod() {
super.MyMethod();
/* Another code */
}
}
Use the super keyword.
super.baseMethod(params);
call the base methods with super keyword and pass the respective params.
call super.myMethod();
Answer is as follows:
super.Mymethod();
super(); // calls base class Superclass constructor.
super(parameter list); // calls base class parameterized constructor.
super.method(); // calls base class method.