Fifth International World Wide Web Conference
Operators (cont.)
- Conditional operators, && and || (operate on
boolean
expressions only):
- Evaluate from left to right
- "short circuit" operators
- Example:
a < b && c > d || e == f
- If a < b evaluates to false, the && subexpression is false and
the evaluation of c > d will be skipped
- If both a < b and c > d evaluate to true, then the expression is
true, and evaluation of e == f will be skipped
- Assignment operator (=)
- To assign a variable from another variable or expression
- May be used in combination with other operators (e.g. "+="
meaning "is incremented by")
- Expression on right hand side converted to type of left hand side operand,
if possible
- No implicit conversions which result in loss of data (must be done via
explicit cast)
Java - An Introductory Language Tutorial
(E.A.Johnson)