When I created a subclass that have two constructors, I need to define a constructor SuperClass(int m)
because my second constructor from the sub class is calling it super()
. This is the part I understand. But the code will not compile unless I define another constructor in the SuperClass like SuperClass(){}
, not SuperClass(int m, int n){}
. Why?
public class SubClass extends SuperClass {
int i,j,k;
public SubClass(int m, int n){
this.i = m;
this.j=n;
}
public SubClass(int m){
super(m);
}
}