This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes creating dynamic object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "creating dynamic object" Watch "creating dynamic object" New topic
Author

creating dynamic object

Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
Hi,

how we can create object for a class dynamically.

Regards,
vishnu
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Using Class#forName and Class#newInstance ?


[My Blog]
All roads lead to JavaRanch
Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
Hi,
i got your point, thaks for your replay.

Regards,
vishnu
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

newInstance calls the constructor without arguments. If you need another one, use Class' getConstructor method, passing the argument types. If you want to find all constructors there's the getConstructors method.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating dynamic object