+ 1
A Constructor can not be overridden in Java......But Why?
2 Respuestas
0
Well, a constructor must have the same name as its class, and you can't have two classes with the same name in a project not even when that class is the children class of the class you want to override the constructor from.
You can polymorph the constructor though, make many constructors with different parameters for a class
e.g.
class thisClass(){
void thisClass(){} // default contructor
void thisClass(int a){} // constructor with parameter a
void thisClass(int a, String b, bool c){} // constructor with parameter a, b,c
public static void main(){
thisClass first = new thisClass();
thisClass second = new thisClass(1);
thisClass third = new thisClass(1, "I am a string", true);
}
}