Define the variable in ONE place at the class level and
either assign it a value where it is defined
or assign it a value in a method.
Do NOT define variables with the same name in a method as...
Type: Posts; User: Norm
Define the variable in ONE place at the class level and
either assign it a value where it is defined
or assign it a value in a method.
Do NOT define variables with the same name in a method as...
It looks like the code NEVER assigns a value to the class instance variable. The class instance variable is what is used in the load() method. but its value is null.
The local variable defined in ...
Why is the variable: pirateWordsList null? Look at where that variable is given a value. Make sure that there is NOT another variable defined that is "shadowing" the class level variable.
Is...
Why is the variable for the ArrayList null? Look at where that variable is given a value. Make sure that there is NOT another variable defined that is "shadowing" the class level variable.
There are two variables on that line.
pirateWordsList
secretPirateWord
What are their values?
You can't be looking at the correct line if this is the line at 108:
for (int i=0;i<num;i++){
There aren't any object references on that line. You do not get the NullPointerException with a...
Look at line 108. What variable on that line has a null value when it is executed?
Use a println() to print the values of all the variables used on line 108 if you can't tell which is null.
Please edit your post and wrap your code with code tags:
YOUR CODE HERE
to get highlighting and preserve formatting.
Look at the line of code mentioned in the error message and find the...