| | |
Creating Objects With User specified Name
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
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,162
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 |
Tag cloud for Java
android api apple applet application arc arguments array arrays automation binary bluetooth c++ chat class classes client code codesnippet component csv database doctype draw ebook eclipse error event exception fractal freeze game givemetehcodez graphics gui html ide image input integer intellij iphone j2me java java.xls javaprojects jmf jni jpanel julia linux list loop loops mac map method methods mobile netbeans newbie number online oracle page parameter plazmic print problem program programming project recursion reporting rotatetext scanner screen sell server set size sms socket sort sourcelabs sql string superclass swing system template test testautomation threads time title tree tutorial-sample windows working






