Reputation: 63
I have this statement:
private JButton button_array [] = {
jButton1, jButton2, jButton3,
jButton4, jButton5, jButton6,
jButton7, jButton8, jButton9
};
This does not seem to work though and gives me an error of "illegal forward reference". How do I fix the statement?
Upvotes: 0
Views: 1605
Reputation: 25950
Your error is not related with your syntax. I guess your jButton1 and other buttons are declared after this statement. Take them upper part of your array declaration. Errors will disappear hopefully.
Legal:
private JButton jButton1, jButton2;
private JButton button_array [] = {jButton1, jButton2};
This one is illegal and gives "Illegal forward reference" error.
private JButton button_array [] = {jButton1, jButton2};
private JButton jButton1, jButton2;
Upvotes: 8