| | |
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 |
6 actuate android api applet application applications array arrays automation balls bank binary bluetooth bold business c++ chat class clear client code codesnippet collections component coordinates database defaultmethod development dice doctype dragging ebook eclipse educational error file formatingtextintooltipjava fractal froglogic game givemetehcodez graphics gui hql html ide ideas image infinite ingres integer intersect invokingapacheantprogrammatically j2me java javaexcel javaprojects jni jpanel jtextarea julia linux list map method methods mobile mysql netbeans openjavafx parameter php problem program programming project recursion repositories scanner scrollbar sell server set sms sort sorting sql sqlserver state storm string sun superclass swing swt threads tree websites windows






