-1

When I compile my code, I get the following:

Display ommitted hash table: 
Exception in thread "main" java.lang.NullPointerException
at Hash.display_hash_table(Hash.java:268)
at Driver.main(Driver.java:20)

Here are the relevant portions of code:

public void display_hash_table() 
{
    System.out.println("Display ommitted hash table: ");

    pw.append("Display ommitted hash table: \n");

    for (int i = 0; i < table.length; i++) {

        System.out.println(String.valueOf(i) + "\t" + table[i].getData());

        pw.append(String.valueOf(i) + "\t" + table[i].getData() + "\n");

    }

    System.out.println("The total number of probes is: " + String.valueOf(this.count_probe) +     "\n");

    pw.append("The total number of probes is: " + String.valueOf(this.count_probe) + "\n");

}

and

    omitted_words.display_hash_table();

Does anyone have any suggestions on what could possibly be my error? Thank you!

Eran
  • 387,369
  • 54
  • 702
  • 768
MatthewS
  • 455
  • 2
  • 7
  • 22
  • On line 268 of your Hash class you try to access an object, that is null. Either it is pw or table. – Dominik Dec 03 '14 at 04:51

1 Answers1

1

table being null is the most likely cause of your exception.

Eran
  • 387,369
  • 54
  • 702
  • 768
  • me being a moron was the cause actually. I needed to include the omitted.txt file, with the omitted words, in the project folder. I figured it out and the program works as expected now. – MatthewS Dec 04 '14 at 00:58