& &&
(x != 0) & (1/x > 1) 1) then do the &. the problem is that for x=0 this will throw an exception.
(x != 0) && (1/x > 1) 1) so if you have x=0 then this is perfectly safe and won’t throw any exception if (x != 0) evaluates to false the whole thing directly evaluates to false without evaluating the (1/x > 1).
EDIT:
exprA | exprB
exprA || exprB
boolean a, b;
Operation Meaning Note
——— ——- —-
a && b logical AND short-circuiting
a || b logical OR short-circuiting
a & b boolean logical AND not short-circuiting
a | b boolean logical OR not short-circuiting
a ^ b boolean logical exclusive OR
!a logical NOT
short-circuiting (x != 0) && (1/x > 1) SAFE
not short-circuiting (x != 0) & (1/x > 1) NOT SAFE
逻辑与按位运算