How does constructor chaining work?
How do you build objects from the inside out by calling constructors?
Printable View
How does constructor chaining work?
How do you build objects from the inside out by calling constructors?
I'm confused by what you are asking, would you mind clarifying?
A constructor can call another constructor in the same class with the this( ... ) syntax; the ellipses represent the parameters for the other constructor; the 'this( ... )' call has to be the first statement of the constructor that wants to call another constructor. Alternatively a constructor can call a constructor witht the super( ... ) syntax, also as the first statement of the calling constructor. If a constructor does none of these, the compiler generates a 'super()' call statement in the calling constructor. If all constructors call another constructor in the same class (with the this( ... ) construct), the compiler will complain about it.
kind regards,
Jos