Can anyone help me figure out where I'm wrong in this?
I keep getting the error "Exception in thread "main" java.lang.NullPointerException" and don't know how to fix it.
public class Brute { public static void main(String[] args) { int[][]chessBoard = new int[8][8]; init(chessBoard); chessBoard = traverse(chessBoard,0,0); print(chessBoard); } public static int [][] traverse(int[][] board, int ver, int hor) { if(boardTraversed(board)) { return board; } board[ver][hor] = 1; if (ver > 1 && hor > 0 && board[ver-2][hor-1] == 0) { return traverse(board, ver-2, hor-1); } if(ver > 1 && hor < 7 && board[ver-2][hor+1] == 0) { return traverse(board,ver-2,hor+1); } return null; } public static void init(int[][] array) { for(int i = 0; i < array[0].length; i++) { for(int a = 0; a < array.length; a++) { array[i][a] = 0; } } } public static void print(int[][] array) { for(int i = 0; i < array[0].length; i++) { System.out.println(); for(int a = 0; a < array.length; a++) { System.out.print(" " + array[i][a] + " "); } } } public static boolean boardTraversed(int board[][]) { for(int i = 0; i < board[0].length; i++) for(int a = 0; a < board.length; a++) if(board[i][a] == 0) return false; return true; } }