A logical AND operator (&&
) is short circuited. It means the right operand is only evaluated if the left operand evaluates to true.
Therefore fName != null
is evaluated first.
If it's true, fName.isEmpty()
is evaluated next, and finally the &&
operator itself is evaluated, since you can't evaluate it before you evaluate its operands.
Here are relevant quotes from the JLS :
15.7 :
The Java programming language guarantees that the operands of operators appear to be evaluated in a specific evaluation order, namely, from left to right.
15.7.1 :
The left-hand operand of a binary operator appears to be fully evaluated before any part of the right-hand operand is evaluated.
15.7.2 :
The Java programming language guarantees that every operand of an operator (except the conditional operators &&, ||, and ? :) appears to be fully evaluated before any part of the operation itself is performed.