How to call the superclass constructor?

If a class called “SpecialClass1” extends your “Class1” class then you can
use the keyword “super” to invoke the superclass’s constructor. E.g.
public SpecialClass1(int id) {
super(id); //must be the very first statement in the constructor.
}
To call a regular method in the super class use: “super.myMethod( );”.

No comments:

Post a Comment