How can i make a constructor for a class? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can i make a constructor for a class?

3rd Oct 2016, 12:58 AM
Xavier Bravo
Xavier Bravo - avatar
3 Answers
+ 2
Xavier i fixed the error in your code the solution is in the codeplayground section, you can have multiple constructors in a class and you forgot the default constructor.
3rd Oct 2016, 3:36 AM
Hector Sulbaran
Hector Sulbaran - avatar
0
You can make a public method in your class with the same name as the name of your class. It is a user constructor.
3rd Oct 2016, 1:12 AM
Evgeny Duz
Evgeny Duz - avatar
0
Thanks. :)
3rd Oct 2016, 1:15 AM
Xavier Bravo
Xavier Bravo - avatar