Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Dynamic object creation in java

Thread Tools

Dynamic object creation in java

rekha rekha is offline
Junior Member
Join Date: Nov 2008
Posts: 4
Hi All,
i have got class name dynamically in a string type, now need to create object of that class and call a method. please help

i tried following code but its not working

String myclassName = textAgeList.item(0).getNodeValue().trim();
// Object myObject = Class.forName(myclassName).newInstance();

Class c= Class.forName(myclassName);
Object m=c.newInstance();
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to (batch) set EXIF date taken and IPTC creation date and creation time for photos with filenames YYMMDDHHMMSS#.jpg? Digital Photography 1 10-04-2005 07:15 PM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
Dynamic creation of object problem Harry F. Harrison ASP .Net 1 08-11-2004 12:49 AM
Dynamic creation of an object instance of a class by name Andre Meyer Python 9 04-08-2004 08:41 AM
Closing a factory method using dynamic object creation. 4Space C++ 16 09-15-2003 07:08 AM