which sign is used in the variable name of a string array
Answers
Answered by
0
Explanation:
You cannot do what you are attempting to do. Java is not a dynamic language that can substitute variable values for names, a la Perl where $x="a"; $$x=3; results in variable $a having the value 3.
The closest thing you can do is use a Map<String,ImageIcon> to associate strings with objects. If you want to associate both an ImageIcon and ColorPanel with a name you would need a wrapper object to hold references to both, and you have a Map<String,MyWrapper> instead.
I would provide a code sample but that would require seeing the code of statsPanel, which you haven't provided. My guess is statsPanel would be (or contain) the Map<> I mentioned above.
Similar questions