Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creating dynamic object

 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

how we can create object for a class dynamically.

Regards,
vishnu
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using Class#forName and Class#newInstance ?
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i got your point, thaks for your replay.

Regards,
vishnu
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic