What is constructor chaining

Table of contents

No heading

No headings in the article.

Constructor chaining is a mechanism through which we can establish the connection between one constructor to another constructor.

through this() and super() we can achieve constructor chaining

Super() is used to establish the connection between one constructor to another constructor of a parent class constructor.

this() is used to establish the connection between same class constructor.

The main purpose of constructor chaining is to initialize the object properties with different values.