Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Initializing Array of JLabels

807599Dec 14 2006 — edited Dec 15 2006
This one's got me scratching my head. The critical lines of code are:
	final JLabel[] labelTable = new JLabel[3][9];
	labelTable[0][0] = new JLabel("Item Name");
And then there are several more lines like the second. The problem I'm having is that, on every line like the second, I get two errors: one complaining that there isn't a closing ] immediately after the very first opening one, and then another error that I just assume is caused by the first error FUBARing the line's syntax.
Why on earth would the compiler not want a value in the array element brackets? I did just create the array, right? It knows labelTable is an array, or it should...
I've tried removing the "final", and I've tried removing the " = new JLabel[3][9]", and neither fixes the problem. Any ideas?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 12 2007
Added on Dec 14 2006
15 comments
1,626 views