Basically I am trying to figure out how to change the variable name while in a loop.
Change the variable name of what? And why?guiArray.get(n) = new Gui(this);
You can't use get this way. I'm not sure what you are trying to do, but you can do this:
Gui someGUI = guiArray.get (n);
or this:
Gui someGUI = new Gui (this);
guiArray.set (n, someGUI);
What are you trying to do?
VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
I am working on a fairly good size open source application so to display all the code is not sensible. Basically my part is: the user will choose how many GUI's to display on a very large GUI. ( The constructor method will bring in the "int numGui" variable which is "the number of GUI's from 1-4 he wants to see" Then from the GUI arraylist which already contains the max 4 GUI's the code will remove however many that is needed so the amount that is left over matches the user defined "int numGui".
That may sound a bit complicated. I will display the previous constructor code that works but is not scalable. ((I'm simply trying to figure out a dynamic way to display a user defined number of GUIs from an already existing GUI class"
This makes sense. I can visualize it.In my previous post if I knew of a way to increment the variable name inside that loop I think I would be fine.
I thought the below line would work
guiArray.get(n) = new Gui(this);
Since the below line basically equals
gui = new DmoGui(this);
"Increment the variable name" - I'm having trouble visualizing what you mean by this term. How do you increment a name, variable or otherwise? Does the name "aaa" turn into "aab", as in "increment" it alphabetically or something?Also just so I do not confuse you any more.
DmoGui(this);
Gui(this);
Are the same thing but variable name changed.
Thanks for trying not to confuse me more, but I think I am more confused. :confused: DmoGui and Gui aren't variable names above, they are class names.
Are you trying to accomplish this below?
ArrayList <Gui> GetGuisToDisplay (ArrayList<Gui> guis, int numGuis)
// assumes that guis contains four elements. ArrayList returned should contain first numGuis elements of guis, which are the Guis to be displayed. Assumes numGuis will be in the range of 0 to 4.
VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
Misperception object reference & accessors.
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241