Java Null Pointer Exception :-(

Posted by John-Michael Reed on Stack Overflow See other posts from Stack Overflow or by John-Michael Reed
Published on 2013-06-29T22:18:32Z Indexed on 2013/06/29 22:21 UTC
Read the original article Hit count: 177

Filed under:
|
|

I've got a Null Pointer Exception in my main that just won't go away and I'm totally out of ideas. The error is on the line "Board[x][y].color = 2;" in which Board is a public, static array of piece objects that contain instance variables like the one "color" that is being set to 2 in the above statement. Pieces is not static - that is there are many different copies of pieces, each with its own data, but only one board. The array has been initialized and defined as both public Piece[][] Board = new Piece[8][8] and public static Piece[][] Board = new Piece[8][8], but no matter how I mess around with it (getting rid of static, putting the variable in another object, etc.), I can't seem to get the error to go away. Help?

© Stack Overflow or respective owner

Related posts about java

Related posts about arrays