| Author |
Constructor - Which are the difference between methods and constructors?
|
André Asantos
Ranch Hand
Joined: Nov 23, 2009
Posts: 234
|
|
Constructor - Which are the difference between methods and constructors? Give me an
exemple please...
André AS
|
André AS
|
 |
W. Joe Smith
Ranch Hand
Joined: Feb 10, 2009
Posts: 710
|
|
Constructors run any time a class is created and don't have a return type.
I recommend reading this.
|
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
|
 |
André Asantos
Ranch Hand
Joined: Nov 23, 2009
Posts: 234
|
|
Thank you very much...
André AS
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32654
|
|
|
The name of the constructor is exactly the same as the name of the class. Remember: no return type.
|
 |
Danish Sualeh
Greenhorn
Joined: Oct 06, 2005
Posts: 11
|
|
To add , constructors should really be concerned with initializing a class instance.
Doing too much work in the constructor may cause problems down the line such as when you want to unit test your code , etc.
In such cases , work should be delegated to methods
|
 |
 |
|
|
subject: Constructor - Which are the difference between methods and constructors?
|
|
|