Results 1 to 1 of 1
Thread: Object from String
-
Object from String
The code snippet below shows how to create an object from a String.
Java Code:Class [] classParm = null; Object [] objectParm = null; try { String name = "com.rgagnon.MyClass"; Class cl = Class.forName(name); java.lang.reflect.Constructor co = cl.getConstructor(classParm); return co.newInstance(objectParm); } catch (Exception e) { e.printStackTrace(); return null; }
Similar Threads
-
Converting object to string
By Preethi in forum New To JavaReplies: 4Last Post: 06-14-2008, 03:29 AM -
How to create object dynamically with class name known in string format
By ranu_gokhe in forum Advanced JavaReplies: 1Last Post: 04-09-2008, 02:15 AM -
Method to write if the string object can be converted to Integer or not.
By Abhishek in forum New To JavaReplies: 4Last Post: 03-25-2008, 12:16 PM -
Object from String (calling method dynamically)
By Java Tip in forum Java TipReplies: 0Last Post: 02-16-2008, 09:22 PM -
String vs Object
By Gilgamesh in forum New To JavaReplies: 1Last Post: 11-28-2007, 10:26 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks