need help : Exception in thread "main" java.lang.NullPointerException
hey, im doing this project and am stuck with this...i have no idea why im getting this error!
Exception in thread "main" java.lang.NullPointerException
at boggleStage1.BoggleBoard.wordPath(BoggleBoard.java:109)
at boggleStage1.BoggleBoard.containsWord(BoggleBoard.java:74)
at boggleStage1.Player.checkOnBoard(Player.java:126)
at boggleStage1.Player.<init>(Player.java:68)
at boggleStage1.BoggleBoard.initBoard(BoggleBoard.java:24)
at boggleStage1.App.<init>(App.java:14)
at boggleStage1.App.main(App.java:39)
here are the classes / code :
private boolean checkOnBoard(String _input) {
boolean checkBoard = false;
System.out.println(word);
if(b1.containsWord(word))
checkBoard = true;
return checkBoard;
}
/**
* Tests whether a given word is found on the Boggle board. 8 way adjacency
* is used and no position in the board can be used twice in the same word.
*
* @return True if the word is found, false otherwise
*
* @param word
*The word to be tested.
*/
public boolean containsWord(String word) {
boolean validWord = false;
char firstLetter = word.charAt(0);
for (int i = 0; i < BOARD_SIZE; i++) {
for (int j = 0; j < BOARD_SIZE; j++) {
boolean[][] usedDice = new boolean[BOARD_SIZE][BOARD_SIZE];
74validWord = validWord || wordPath(i, j, word, usedDice);
}
}
return validWord;
}
/**
* Helper method for containsWord. Will test if the first character of a
* String is found at a given location and ensure that it has not been used
* already in this particular path. If it is found and has not been used,
* will then continue to look for the remainder of the word using 8 way
* adjacency.
*
* @return True if the word length gets to zero, false if the letter
* is not found or the position has been used.
*
* @param row
*The row to be tested
* @param col
*The column to be tested
* @param word
*The word that is path is being found for
* @param usedDice
*An array that retains positions of the board that have already
*been used.
*/
private boolean wordPath(int row, int col, String word, boolean[][] usedDice) {
if (word.length() == 0) {
return true;
}
char testLetter = word.charAt(0);
109if (_board[row][col] != testLetter || usedDice[row][col] == true) {
return false;
}
usedDice[row][col] = true;
boolean validPath = false;
boolean rowUp = false;
boolean rowDown = false;
boolean colLeft = false;
boolean colRight = false;
if (row - 1 >= 0) {
rowUp = true;
}
if (row + 1 < BOARD_SIZE) {
rowDown = true;
}
if (col - 1 >= 0) {
colLeft = true;
}
if (col + 1 < BOARD_SIZE) {
colRight = true;
}
if (rowUp) {
validPath = validPath
|| wordPath(row - 1, col, word.substring(1, word.length()),
usedDice);
if (colLeft) {
validPath = validPath
|| wordPath(row - 1, col - 1, word.substring(1, word
.length()), usedDice);
}
if (colRight) {
validPath = validPath
|| wordPath(row - 1, col + 1, word.substring(1, word
.length()), usedDice);
}
}
if (rowDown) {
validPath = validPath
|| wordPath(row + 1, col, word.substring(1, word.length()),
usedDice);
if (colLeft) {
validPath = validPath
|| wordPath(row + 1, col - 1, word.substring(1, word
.length()), usedDice);
}
if (colRight) {
validPath = validPath
|| wordPath(row + 1, col + 1, word.substring(1, word
.length()), usedDice);
}
}
if (colLeft) {
validPath = validPath
|| wordPath(row, col - 1, word.substring(1, word.length()),
usedDice);
}
if (colRight) {
validPath = validPath
|| wordPath(row, col + 1, word.substring(1, word.length()),
usedDice);
}
return validPath;
}
Please help, i have no idea why its not working!
Thanks in advance

