New object (with string)

Hello,I have a function which is getting as an input a string variable and needs to create an new object that has the same name as the input string.How can I do it?thanks
[198 byte] By [codingGa] at [2007-11-27 9:20:57]
# 1
Object o = Class.forName(yourInput).newInstance();~
yawmarka at 2007-7-12 22:14:29 > top of Java-index,Java Essentials,New To Java...
# 2

> Hello,

> I have a function which is getting as an input a

> string variable and needs to create an new object

> that has the same name as the input string.

> How can I do it?

For me the main question is why you want to do this? What difference is the name of the as long as you can find the object. I wonder if there is a better way of implementing what it is you want to do.

For instance, would tying your object to the string via HashMap be a better solution?

Do you have any sample code or pseudocode showing what you want to do?

Message was edited by:

petes1234

petes1234a at 2007-7-12 22:14:29 > top of Java-index,Java Essentials,New To Java...