DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   Use of constructors (http://www.daniweb.com/forums/thread93617.html)

tinamary Oct 19th, 2007 10:24 am
Use of constructors
 
what is the use of constructors in java when we can intialize objects directly

Ezzaral Oct 19th, 2007 12:04 pm
Re: Use of constructors
 
Can you elaborate a little more on the question? All object creation is done through constructors. If no constructor is specified, the compiler will supply a default empty constructor that basically does nothing. If you wish to provide info that initializes some values in the object when it's created, you provide a constructor for those parameters and initialize those values in that constructor.

peter_budo Oct 19th, 2007 12:06 pm
Re: Use of constructors
 
Do you think that user of your application will be interested in reading your code and seting all variables by him self? Or do you think all variables are always initialized?


All times are GMT -4. The time now is 5:17 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC