Why do we use an "initialize method" instead of a constructor? At face value, it looks like they both do the same thing.
United States of America
Why do we use an "initialize method" instead of a constructor.
You must be signed in to leave a comment
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.
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).