vendredi 26 juin 2015

null pointer exception inside if statement [duplicate]

This question already has an answer here:

so i have this bit of code

 if(nodes.get(x) != null)
 {
    //System.out.println("node is not null "+nodes.get(x));
    //node is a string which is parameter of the method fed in 
    //and nodes is an array list 
    if(node.equals(nodes.get(x)))
    {
        existing = true;
    }
 }

I keep getting a null pointer exception on the line of the if statement. I realize this is something probably very simple, but please help. nodes.get(x) will be null at some times, so however i fix this, i need a way to circumvent this if statement.

Aucun commentaire:

Enregistrer un commentaire