Well Brad, I don't know if you're being serious or not.
But in case you are, a constructor is actually a specific kind of method that is automatically invoked when an object is created. It usually contains any initialization code that the object needs. There is a lot more to it, but that's the basic gist (sp?).
Well i was being serious i just phrased it very ignorantly...
I'm just an aspiring programmer right now and going to university to learn.
I should have taken a few seconds to phrase exactly what i wanted to know..
Here i go: Is there any other specific purpose of a constructor besides the initilization code of the created object?
As Supermole as said, constructor has no other purpose than initializing the object. I should add that you can define as many constructors as you want as soon as they have differents parameters I explain :
Code:
toto = new myClass();
will call
Code:
public myClass()
constructor while
Code:
toto = new myClass("firstParm");
will call
Code:
public myClass(String parm)
constructor. So many constructors can be usefull to instanciate your class many ways. Water is not bad as long as it stays out human body ;-)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.