This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Creation of Object without New & Construcotr Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Creation of Object without New & Construcotr" Watch "Creation of Object without New & Construcotr" New topic
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
    
    6

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Creation of Object without New & Construcotr
 
Similar Threads
String x = "hi" ; garbage collected ?
IBM RAD - Upgrade the JDK compliance to 1.5
creation of object
WA #1.....word association
Create object Without new operator