I have the following situation, where my program terminates with a NullPointerException during the function. What can I do to make this function work?
UPDATE
else if (str == null)
emptyLinks.add(newPageLinks.get(i).getText() + "at link: " + str);
The problem is not in:
else if (str == null)
The actual problem is in:
do something
In your do something you are trying to access a property or method of a null object which isn't possible and will throw an NPE.
Normally if you want to access methods from an object that could be null
you do a null
check like so:
if (str != null)
do something
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments