NullPointerExcetion Native Method Accessor… Hashing Words Issue
问题 I am writing a project that reads a file and sorts "Words". This code compiles correctly, yet then it gives me a null pointer exception. Any Ideas? import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; import java.util.Hashtable; public class Lab { Hashtable<String, Word> words = new Hashtable<String, Word>(); public void addWord(String s, int i) { if (words.containsKey(s)) { words.get(s).addOne(); words.get(s).addLine(i); } else { words.put(s, new Word(s));