| | |
Creating Objects With User specified Name
![]() |
•
•
Join Date: Oct 2008
Posts: 26
Reputation:
Solved Threads: 1
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"
.
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"
.
Last edited by babusek; Nov 17th, 2008 at 8:05 am.
•
•
Join Date: Aug 2008
Posts: 1,160
Reputation:
Solved Threads: 137
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
if so you can't do that in java
you can use an ArrayList or HashMap to store a name and a class
Java Syntax (Toggle Plain Text)
String userSpecifiedName = "SunServer"; HashMap<String, Simple> map = new HashMap<String, Simple>(); Simple simpleClass = new Simple(); map.put(userSpecifiedName, simpleClass);
Last edited by dickersonka; Nov 17th, 2008 at 9:49 am.
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
![]() |
Similar Threads
- Encrypt File using User Supplied Password (VB.NET)
- Creating objects within objects dynamically (C++)
- Creating a popup menu on mouse over (JavaScript / DHTML / AJAX)
- javascript clone objects (JSP)
- Moving Objects in Turbo C++ (C++)
- Urgent Help Needed!!!! Plzzz (Java)
- Java practice questions (Java)
- Dynamic memory allocation homework (C++)
- Create a Desktop Shortcut that Locks a Windows XP-Based Workstation (Windows tips 'n' tweaks)
Other Threads in the Java Forum
- Previous Thread: specify libraries class path in JBoss
- Next Thread: Menu App
| Thread Tools | Search this Thread |
-xlint android api applet application array arrays automation bi binary blackberry block bluetooth chat class client code compile compiler component database developmenthelp eclipse error event fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide image int integer j2me j2seprojects java javac javaprojects jetbrains jni jpanel jtable julia learningresources lego linux list login loops mac main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying number online pearl problem program programming project qt recursion scanner screen server set singleton sms sort spamblocker sql string swing system textfields thread threads time title tree tutorial-sample update variablebinding windows working xor






