Wednesday, 25 April 2018

Core Java: Short-Circuit Operation

The logical AND (&&) and OR (||) operators are known as short-circuit operators, meaning that the right operand will not be evaluated if the result can be determined by the left operand.
 For example:
false && ... gives false; true || ... give true without evaluating the right operand.
  
This may have adverse consequences if you rely on the right operand to perform certain operations, e.g. false && (++i < 5) but ++i will not be evaluated.

No comments:

Post a Comment

Please write your view and suggestion....