Hello,
I keep receiving the Null Pointer Exception error in my code and I am not sure how to fix it. The program I am working on is a Word Guess program that is kind of like jeopardy. I am coding this in Eclipse, by the way.
public class WordGuess { //global variables static Scanner myScanner; static Scanner datScanner; static File inFile; static String[] words = new String[10]; static String guessWord; static String dashWord; static String numCtr; static String guess; public static void input() { int i = 0; int guessCtr = 15; dashWord = guessWord; dashWord.replaceAll("[A-Z]", "-"); //this is where I get the error System.out.println("Guesses left: " + guessCtr + " " + dashWord); System.out.print("Enter letter: "); guess = myScanner.next(); guessValid(); for(i = 0; i < guessWord.length() && guessCtr > 0; i++) { if(guessValid()) { if(guessWord.substring(i, i + 1).equals(guess)) { guess.replace(dashWord.substring(i, i + 1), guess); } else { guessCtr--; } System.out.println("Guesses left: " + guessCtr + " " + guessWord); System.out.print("Enter letter: "); guess = myScanner.next(); } } System.out.println("Sorry, you fail!"); }