Constructor | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Constructor

What is the main purpose of a constructor?

9th Feb 2018, 7:02 AM
Keraznam
Keraznam - avatar
5 Answers
9th Feb 2018, 7:33 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 8
Constructors are invoked to create objects from the class blueprint and also to initialize the instances of your class. You may refer to the documentation: https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html
9th Feb 2018, 7:12 AM
Dev
Dev - avatar
+ 2
when you want to intialize your data members in the object , then go for constructors.
9th Feb 2018, 7:48 AM
Bharath_Teki 🇮🇳
Bharath_Teki 🇮🇳 - avatar
0
💋💋
16th Dec 2019, 12:29 PM
Ali Aliقغفعل
Ali Aliقغفعل - avatar
0
ههههه
16th Dec 2019, 12:33 PM
Ali Aliقغفعل
Ali Aliقغفعل - avatar