WHY is it not def? PLZ HELP IT IS VERY SIMPLE!!
ok I have an obj called Cell, and i made a 2D array, and I try to rest eveycell,
What is wrong ???
Code:
package thegame;
class Cell {
boolean occupied = false;
char own = ' ';
}
/**
*
* @author joseph
*/
class Queendom {
public static final int MAX_LENGHT = 400;
Cell [][]Board = new Cell[400][400];
private int lenght = 0;
public void reset(){
for(int i=0;i<lenght;i++){
for(int j=0;j<lenght;j++){
Board[i][j].occupied = false;
Board[i][j].own = ' ';
}
}
}
now, I have in my main :
Code:
public class The_Game {
public static void main(String[] args) {
// TODO code application logic here
Queendom Q = new Queendom();
Q.reset();
}
}
But the when I cal the Q.reset(), and it look at the Board[i][j].occupied = false; it fail, and says:
Exception in thread "main" java.lang.NullPointerException
at thegame.Queendom.reset(Queendom.java:33)
at thegame.The_Game.main(The_Game.java:17)
PLZ help me on this !!!!
Thanks a lot