+= , -= , <<= ,
>>= , >>>= ,
&= , ^= , |=
arglist, method body
Operand number and type
The fourth column of Table 2-4 specifies the number and type of the operands
expected by each operator. Some operators operate on only one operand; these are
called unary operators. For example, the unary minus operator changes the sign of a
- n // The unary minus operator
Most operators, however, are binary operators that operate on two operand values.
The - operator actually comes in both forms:
a - b // The subtraction operator is a binary operator
Java also defines one ternary operator, often called the conditional operator. It is like
an if statement inside an expression. Its three operands are separated by a question
mark and a colon; the second and third operands must be convertible to the same
x > y ? x : y // Ternary expression; evaluates to larger of x and y
In addition to expecting a certain number of operands, each operator also expects
particular types of operands. The fourth column of the table lists the operand types.
Some of the codes used in that column require further explanation:
An integer, floating-point value, or character (i.e., any primitive type except
boolean ). Autounboxing (see “Boxing and Unboxing Conversions” on page 87 )
means that the wrapper classes (such as Character , Integer , and Double ) for
these types can be used in this context as well.
A byte , short , int , long , or char value ( long values are not allowed for the
array access operator [ ] ). With autounboxing, Byte , Short , Integer , Long ,
and Character values are also allowed.
An object or array.