+ 2
Is it possible to call one constructor from another in Java?
3 Antworten
+ 8
Omkar Shinde
Java constructor chaining is a method of calling one constructor with the help of another while considering the present object. Within same class: It can be done using this() keyword for constructors in the same class.
source:
https://data-flair.training/blogs/constructor-chaining-in-java/
I hope I was helpful
+ 5
Omkar Shinde
Do you mean this?
In the constructor of the first class I created an object of the second class. As you can see, creating an object of first, both constructor are called.
https://code.sololearn.com/cb6XKtn3O8gh/?ref=app
+ 3
Yes