Quote:
import javax.swing.*;
import java.lang.*;
public class Lab5Program1 {
public static int inputFromFile (String filename)
{
TextFileInput in = new TextFileInput (filename);
int lengthfilled = 0;
String line = in.readLine();
while(line!=null) {
wordArray[lengthfilled] = line;
lengthfilled ++;
line = in.readLine();
}
in.close();
return lengthfilled;
}
public static String isOrIsNot, inputWord;
public static String wordArray [];
public static void main(String[] args) {
inputFromFile ("Lab5Input.txt");
while(true)
{
inputWord = JOptionPane.showInputDialog(null,"Enter a word in all lower case:");
if(inputWord.equals("Stop")) System.exit(0);
if (wordIsThere(inputWord,wordArray))
isOrIsNot = "is";
else
isOrIsNot = "is not";
JOptionPane.showMessageDialog(null,"The word "+inputWord+" "+
isOrIsNot+" on the list.");
}
}
public static boolean wordIsThere(String findMe, String[] theList){
for(int i=0;i<theList.length;i++){
if(findMe.equals(theList[i])) return true;
}
return false;
}
}
However, when I compile it tells me that I have a "Null Point Exception". The problem lines (according to the compiler) are indicated in bold. Can anyone tell me how to fix it?