NullPointerException
I am trying to write a spell checker class from scratch in java, and a spell checker test program in main but I got stuck because public int quadraticProbing(String[] hashArray, int initial_index, int collision) beginning from line 256 of SpellCheckHashTable.java is throwing a NullPointerException in 3 places as shown below.
Exception in thread "main" java.lang.NullPointerException
at SpellCheckHashTable.quadraticProbing(SpellCheckHashTable.java:265)
at SpellCheckHashTable.insert(SpellCheckHashTable.java:209)
at SpellCheckHashTableDemo.main(SpellCheckHashTableDemo.java:48)
I am trying to have the class use OOP principles of encapsulation, private variables, and getter and setter methods. Apart from hashcode() my program would not use predefined hashing methods from java. The program will:
- Read a set of words W, from a words.txt file and store them in a hash table;
- Implement a spellCheck function that performs a spell check on a string s, entered by user at the console, using the words in the hash table as the dictionary.
- Return an iterable collection of correctly spelled words.
- If s is not in W (the hash table) then return a list of words in W that could be a correct spelling of s.
- Handle all the ways that s might be a mispelling of a word in W, including swapping adjacent characters, inserting a single character between two adjacent characters, omitting a single character, replacing a character with another character, and possibly phonetic substitutions.
I have began but got stuck with my program throwing a NullPointerException that I have not yet been able to resolve. If you want, I will be happy to share my files with you.
Thanks in advance
Respectfully yours
Emmanuel
Trending now
This is a popular solution!
Step by step
Solved in 2 steps