AP® Computer Science A glossary
Short-circuit evaluation
Course: AP® Computer Science A Shows up in: Unit 2: Selection and Iteration
When the first operand of && or || already decides the result, the second Boolean expression is not evaluated.
Appears in the course and exam description (CED): 2.5.A.2
false && anything is false and true || anything is true, so Java skips anything. Put a safety check (such as count != 0 or name != null) on the left.
int games = 0;
int points = 40;
System.out.println(games != 0 && points / games > 10);
Output:
false Learn it properly, with a checkpoint 2.5 Compound Boolean Expressions