Call a class using its name (in String object)??

Z

Z

I have a name of a class in a string object. Is there a way to call
that class using its name in a string object? I am using reflection
and I have the name of the class; is there a way to call it using that
name?

Thanks
 
D

Daniel Pitts

I have a name of a class in a string object. Is there a way to call
that class using its name in a string object? I am using reflection
and I have the name of the class; is there a way to call it using that
name?

Thanks

You don't call a class. You can load a class and instantiate it, its
called Reflection.

Don't use reflection! Well, don't use it unless you have a *REALLY*
good reason to.
<http://virtualinfinity.net/wordpress/program-design/2007/01/11/the-
dangers-of-reflection-or-put-down-that-mirror/>

Having said that, if you really want to know how, google for Java
Reflection. You can load classes, instantiate objects, call methods,
access fields, etc...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top