-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
  • 374,785
  • 51
  • 663
  • 734
user3727648
  • 413
  • 2
  • 6
  • 21
  • 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
  • 374,785
  • 51
  • 663
  • 734
  • 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. – user3727648 Dec 04 '14 at 00:58