Tuesday, February 26, 2013

super()


package test;

public class Super {
protected int a;
protected Super(int a) { this.a = a; }
}

----------------


package test;

public class Sub extends Super{
public Sub(int a) { super(a); }
public Sub() { this.a = 5; }//implicitly add super(); but the Super class only has Super(int a)
}

ERROR: Implicit super constructor Super() is undefined. Must explicitly invoke another constructor

No comments:

Post a Comment