Short-circuiting the evaluation of an expression means that only a part of the expression needs to be evaluated before finding its value. For example:
a == null || a.size() == 0
If a is null, the a.size() == 0 subexpression won't be evaluated, because the boolean operator || evaluates to true if one of its operands is true.
Similarly, for this expression:
a != null && a.size() > 0
If a is null, then the a.size() > 0 won't be evaluated, because the boolean operator && evaluates to false if one of its operands is false.
In the above examples the boolean operators && and || are said to be short-circuit, given the fact that the second operand might not be evaluated if the value of the first operand is enough to determine the value of the whole expression. For comparison, the & and | operands are the equivalent non-short-circuit boolean operators.
answered 2012-02-18T21:41:50.680