Java Reference
In-Depth Information
At run time, the first operand expression of the conditional expression is evaluated first. If
necessary, unboxing conversion is performed on the result.
The resulting
boolean
value is then used to choose either the second or the third operand ex-
pression:
• 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
type of the conditional expression as determined by the rules stated above.
The operand expression not chosen is not evaluated for that particular evaluation of the
conditional expression.
15.26. Assignment Operators
There are 12
assignment operators
; all are syntactically right-associative (they group right-
to-left). Thus,
a=b=c
means
a=(b=c)
, which assigns the value of
c
to
b
and then assigns the
value of
b
to
a
.
AssignmentExpression:
ConditionalExpression
Assignment
Assignment:
LeftHandSide AssignmentOperator AssignmentExpression
LeftHandSide:
ExpressionName
FieldAccess
ArrayAccess
AssignmentOperator: one of
= *= /= %= += -= <<= >>= >>>= &= ^= |=
The result of the first operand of an assignment operator must be a variable, or a compile-
time error occurs.
This operand may be a named variable, such as a local variable or a field of the current
or an array access (§
15.13
).