Why do we use an "initialize method" instead of a constructor? At face value, it looks like they both do the same thing.
Why do we use an "initialize method" instead of a constructor.
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
MeenaExpert
28 March, 04:28
Initialize methods are used to perform the execution of certain tasks or statements but constructors are used to initializing the objects only.
0
Thomas
25 March, 08:19
Must have been a didactic decision. First you learn something fields, about setter, about the fact that you can initialize several fields with one (initialize) method and later that there is also a constructor for this.
You will come across initialize methods more often, because it is the best way in certain situations (factory).
+1