| Author |
Creation of Object without New & Construcotr
|
raghava rao
Greenhorn
Joined: Dec 03, 2004
Posts: 3
|
|
Hi All, How to Instantiate a Class without NEW Operator and without using Constructor? Thanks in Advance Raghav
|
 |
Mike Gershman
Ranch Hand
Joined: Mar 13, 2004
Posts: 1272
|
|
|
The newInstance() method of Class creates an object using the object's default constructor.
|
Mike Gershman
SCJP 1.4, SCWCD in process
|
 |
Jeroen Wenting
Ranch Hand
Joined: Oct 12, 2000
Posts: 5093
|
|
|
You can't create an object without a call to some constructor, whether a default no-argument constructor or a user defined constructor.
|
42
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9950
|
|
If you have a factory object, you won't ever SEE the call to a constructor... Sure, the makeSportsCar method probably calls a constructor, or it calls a method that calls a constructor... but if i don't own the autoPlant class, and don't have access to it's source, i won't ever be able to see the constructor.
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
 |
|
|
subject: Creation of Object without New & Construcotr
|
|
|