I'm getting the error "Exception in thread "main" java.lang.NullPointerException" when I try to read an array value. Here is the code that I think causes the error.
class Board
{
private static char[][] board;
public Board(int r, int c)
{
setRow(r);
setColumn(c);
char board[][] = new char[row][column];
}
public void getBoard()
{
for (int c = 1;c <= getColumn()-1 ;c++)
{
System.out.print("\t"+c);
}
System.out.print("\n");
for (int r = 1; r <= getRow()-1; r++)
{
System.out.print(r);
for (int c = 1; c <= getColumn(); c++)
{
System.out.print("\t" + board[r][c]); //I think board[r][c] is causing it.
}
System.out.println("");
}
return;
}
}
I can upload the whole file if need be.
Any help would be appreciated, this kept me up last night.
-1to the lastforloop,for (int c = 1; c <= getColumn()-1; c++)`