mercredi 8 juin 2016

How to correct use an if/else statement looking for a null value?

My current code is as follows (note that getId() returns a string value):

 if(person.getId()==null){

    //do something
else{

    //do something else

}

However, I am still getting a null Pointer exception if the value for person.getId() is null.

How can I fix this?

Aucun commentaire:

Enregistrer un commentaire