Programming and Problem Solving with Java

(やまだぃちぅ) #1
9.3 Additional Java Operators | 449

Operator Remarks
Combined Assignment Operators
+= Add and assign


  • = Subtract and assign
    *= Multiply and assign
    /= Divide and assign
    %= Remainder and assign


Increment and Decrement Operators
++ Pre-increment Example: ++someVar
++ Postincrement Example: someVar++
-- Pre-decrement Example: --someVar
-- Postdecrement Example: someVar--

Bitwise Operators Integer operands only
<< Left shift
>> Right shift with sign extension
>>> Right shift with zero extension
& Bitwise AND
| Bitwise OR
^ Bitwise EXCLUSIVE OR
~ Complement (invert all bits)

Boolean Full Evaluation Operators Boolean operands only
& Boolean AND
| Boolean OR
^ Boolean EXCLUSIVE OR

More Combined Assignment Operators Integer operands only
<<= Shift left and assign
>>= Shift right with sign extension and assign
>>>= Shift right with zero extension and assign
&= Bitwise AND and assign
|= Bitwise OR and assign
^= Bitwise EXCLUSIVE OR and assign

Other operators
instanceof Type comparison object instanceofClassName
?: Conditional operator Form: Expr1 ?Expr2 :Expr3

Table 9.1 Additional Java Operators

Free download pdf