I'm getting "java.lang.NullPointerException" when I run the following code:
while(StringName[PlaceString] != null){
StringCounter = 0;
while(StringCounter < StringName[PlaceString].length()){
System.out.println("PlaceString: " + PlaceString + " PlaceLine: "
+ PlaceLine + " Length of string: " + StringName[PlaceString].length());
//Does stuff with string
}}
The output is:
PlaceString: 0 PlaceLine: 0 Length of string: 2
Exception in thread "main" java.lang.NullPointerException
The root of the error is:
while(StringCounter < StringName[PlaceString].length()){
although it runs the next line that prints variable's values. I can't figure out why it's complaining about a NullPointer when it can print their values.
Edit: Since I'm not getting a java.lang.StringIndexOutOfBoundsException, the question:
Java substring : string index out of range
didn't help.