What is constructor chaining

Mitali sahuMitali sahu
1 min read

Table of contents

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.

0
Subscribe to my newsletter

Read articles from Mitali sahu directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mitali sahu
Mitali sahu