java - Quick question on If statements with multiple conditions -
possible duplicate:
&& (and) , || (or) in java if statements
this question should have known answer years ago if writing if statement in java has if(x != null && y == null && x.equals(z)) safe? assume if statement conditions interpreted left right checking if x != null begin assure no null pointer exception thrown (at least x) on x.equals(z) part of condition. accurate?
yes. it's called short-circuited logic: http://en.wikipedia.org/wiki/short-circuit_evaluation.
Comments
Post a Comment