mercredi 27 janvier 2021

Is it valid to add a Null check and access the Integer value in the same line of if condition in Java [duplicate]

Say

class Person{
    Integer height;
    integer weight;
}

is it valid to check like this?

Person p = new Person();
if (p.height !=null && p.height >= 1 && p.weight >=1 ){}

Aucun commentaire:

Enregistrer un commentaire