Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Illegal forward reference

When trying to declare a static array in my program I receive a static forward reference error, i'm not sure what I am doing wrong here...

static Square fieldGrid [ ] [ ] = new Square [ ROWSIZE ] [ COLSIZE ]; 

this is what I am using.

like image 727
Troy Avatar asked Feb 28 '23 06:02

Troy


1 Answers

The preferred syntax is:

 static Square[][] fieldGrid = new Square [ ROWSIZE ] [ COLSIZE ];

Also, have you declared and initialized ROWSIZE and COLSIZE by the time you make this declaration?

like image 191
Justin Ethier Avatar answered Mar 05 '23 15:03

Justin Ethier