Java Language Specification 15.25. Conditional Operator ? : says:
At run time, the first operand expression of the conditional expression is evaluated first. ...
The resulting boolean value is then used to choose either the second or the third operand expression:
If the value of the first operand is true, then the second operand expression is chosen.
If the value of the first operand is false, then the third operand expression is chosen.
The chosen operand expression is then evaluated and the resulting value is converted to ...
The operand expression not chosen is not evaluated for that particular evaluation of the conditional expression
That means:
- the condition is evaluated first,
- only one of the second or third operand is evaluated
Note: the Conditional Operator (? :,) as its name suggest, is a normal operator, it is not only valid in assignments!
It can be used in any expressions: assignment, array index, method arguments, conditionals [if, for, switch] ... (assignment is also an Expression, = is the Simple Assignment Operator.)