wood burning stoves 2.0*
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
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: 14688
    
  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: 19790
    
  20

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