JWR 010510

Summary of Java Operators

Operator Description Example
. (period, "dot") Class member x.toString()
[ ] Array element x[1]
( ) Parentheses (x+1)*2
instanceof Test object type x instanceof Object
~ (tilde) Ones complement ~0xF7
! (exclamation, "not") Logical negation !booleanVar
++ Increment by one x++ ++x
-- Decrement by one x-- --x
* (asterisk, "times") Multiply x*y
/ Division x/y
% Modulus x%y
+ Addition, Concatenation x+y
- Subtraction x-y
<< Left shift x << 2
>> Signed right shift x >> 2
>>> Unsigned right shift x >>> 2
> Greater than x > y
< Less than x<y
>= Greater than or equal to x >= y
<= Less than or equal to x <= y
== Equals x == y
!= Not equal x != y
& bitwise and x & y
^ bitwise exclusive or x ^ y
| bitwise or x | y
&& logical and x && y
|| logical or x || y
?: ternary operator x ? y : z
= assignment operator x = y
op= assignment with operator x op= y
1