OK, I'm still in the learning process with Java, but I have a decent bit of experience with JScript and QBasic.
I'm trying to create a for loop to access several buttons that I've created, variable names b1, b2, b3, b4....b16.
What class/command do I need to use to evaluate a string as a variable name so I can do this? (I.E. the red highlighted portion of the class below...I know that's wrong though, but it hopefully demonstrates what I'm wanting)
I'm trying to create a for loop to access several buttons that I've created, variable names b1, b2, b3, b4....b16.
What class/command do I need to use to evaluate a string as a variable name so I can do this? (I.E. the red highlighted portion of the class below...I know that's wrong though, but it hopefully demonstrates what I'm wanting)
Code:
JButton b1, b2, b3, b4, b5;
public static void main(string[] args)
{
for(byte buttoN = 1; buttoN <= 5, buttoN++)
{
[red]eval("b"+buttoN)[/red] = new JButton();
}
}