| | |
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,158
Reputation:
Solved Threads: 136
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 |
addball android applet application apps array automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) button card class classes client code collision columns component constructor crashcourse css database designadrawingapplicationusingjavajslider draw eclipse ee error eventlistener exception expand fractal free game givemetehcodez graphics gui guidancer html ide image integration intellij j2me java javaarraylist javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia jvm linux loan loop method migrate mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle phone physics plazmic print problem program programming project radio scanner server service set sharepoint smart sms smsspam software sql subclass support swing textfield threads tree trolltech unlimited utility windows






