So, I have a class Square and I am trying to use an array for it board. Here is my code:
public class Square{
public int pcolor;
public int contains;
public int xPos;
public int yPos;
Square(int xp,int yp,int pc,int cont){
xPos=xp;
yPos=yp;
contains=cont;
pcolor=pc;
}
};
Square[] board = new Square[64];
board[0].xPos=0;
This gives me unexpected token: [ on board[0].xpos=0;. Can anyone help me resolve this?
EDIT:
OK, I moved board[0].xpos=0; inside a method; now it gives me NullPointerException. What do I do?