0

I am struggling to figure out why the initialization of a multidimensional array in java is not working properly when I try to insert elements in the array one by one. My code is shown below:

public char[][] board;
public Board() {
      for (int i = 0; i < ROWS; i++) {
          for (int j = 0; j < COLUMNS; j++) {
              board[i][j] = ' ';
          }
      }
  }

I tried to initialize the board array in setting it to "new char[6][7]" but that did not work. ROWS = 6 and COLUMNS = 7. Any help to figure out why this is giving such an error would be greatly appreciated. Thank you!

CSStudent123456
  • 173
  • 1
  • 4
  • 16

1 Answers1

0

public char[][] board = new char[ROWS][COLUMNS];