HI Folks ,

Sorry if it is the Repeated Question....

---> I want to Create An Object for a Class With user specified name.?

Example :
Class Name : Simple
User Specified Name for a Object : SunServer

i want like this

Simple "userSpecified Name" = new Simple();
how to replace the "userSpecified Name " variable in the above line with SunServer..

String UserSpecified = SunServer;
:'( Simple UserSpecified = new Simple();:'(

Above line is Wrong bcz we already defined UserSpecified Variable as a String Type and we cant create an Object for a class(Simple) with same variable.

i want to do create Objects with name as User specified "Something like at Runtime"

9 Years
Discussion Span
Last Post by babusek

are you wanting dynamic variable names?

if so you can't do that in java
you can use an ArrayList or HashMap to store a name and a class

String userSpecifiedName = "SunServer";
HashMap<String, Simple> map = new HashMap<String, Simple>();

Simple simpleClass = new Simple();
map.put(userSpecifiedName, simpleClass);
Votes + Comments
Yeah, he seems to be wanting a map. Not a very clear question though :)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.