A constructor from a subclass can call constructors from the superclass, but they're not inherited as such.
To be clear, that means if you have something like:
public class Super
{
public Super(int x)
{
}
}
public class Sub extends Super
{
public Sub()
{
super(5);
}
}
then you can't write:
new Sub(10);
because there's no Sub(int)
constructor.
It may be helpful to think of constructors as uninherited static methods with an implicit parameter of the object being initialized.
From the Java Language Spec, section 8.8:
Constructor declarations are not members. They are never inherited and therefore are not subject to hiding or overriding.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…