Okay, its a simple question, I dont have any problem with it but I just want to be sure. Is it correct if I do something like this ?
if (person != null && person.getAge > 20) {...}
can I do this? null check and object access on the same line? is this correct? or I have to make an inner statement on the null check statement like:
if (person != null)
{
if (person.getAge() > 20) {...}
}
imo, the first statement wouldnt throw a NPE, but I needed feedback from professionals...
Generally my question is that, on if statements with &&, if the first boolean is false, will the JVM stop executing the if statement or it will check it all ?