Error
Constructor Call must be the first statement in a constructor
Error Type
Compile Time
Sample Code
class ChildClass extends ParentClass {
public ChildClass(){
System.out.println("Within Constructor");
super();
}
}
public ChildClass(){
System.out.println("Within Constructor");
super();
}
}
Cause
Call to Super class constructor should be the first statement in the sub class constructor.
Resolution
Call super constructor as the first statement in the child class constructor.
class ChildClass extends ParentClass {
public ChildClass(){
super();
System.out.println("Within Constructor");
}
}
public ChildClass(){
super();
System.out.println("Within Constructor");
}
}