Red Security
What is constructor chaining in Java? - Printable Version

+- Red Security (https://redsecurity.info/cc)
+-- Forum: Programming (https://redsecurity.info/cc/forumdisplay.php?fid=5)
+--- Forum: Java (https://redsecurity.info/cc/forumdisplay.php?fid=7)
+--- Thread: What is constructor chaining in Java? (/showthread.php?tid=1435)



What is constructor chaining in Java? - Mr.Kurd - 03-20-2020

In The Name OF Allah
Al-Salam Alekum




What is constructor chaining in Java?

In Java, constructor chaining is the process of calling one constructor from another with respect to the current object. Constructor chaining is possible only through legacy where a subclass constructor is responsible for invoking the superclass’ constructor first. There could be any number of classes in the constructor chain. Constructor chaining can be achieved in two ways:
  1. Within the same class using this()
  2. From base class using super()



Wa Salam Alekum