0

Yes, I know this has been brought up alot. Yes, I know the answer will probably be something stupid and simple that I missed.

public char [] [] board;

 public Gameboard(boolean setup){

    for(int i = 0; i < 7; i++){
      for(int j = 0; j < 7; j++){
        board[j][i] = '-';
      }
    }

I am initializing a blank game board, (8x8). The dash marks represent blank spaces, and I am initializing the whole board, and plan to add pieces later.

This is the error.

java.lang.NullPointerException
    at Gameboard.<init>(Gameboard.java:9)
    at Student_Runner_Gameboard.main(Student_Runner_Gameboard.java:4)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:267)

Thanks for any help in advance.

Nate
  • 1
  • 1

0 Answers0