Operator | Example | Actual operation |
+= | x += 10 | x = x + 10 |
-= | x -= 10 | x = x – 10 |
*= | x *= 10 | x = x * 10 |
/= | x /= 10 | x = x / 10 |
%= | x %= 10 | x = x / 10 |
<<= | x <<= 10 | x = x << 10 |
>>= | x >>= 10 | x = x >> 10 |
&= | x &= 10 | x = x & 10 |
^= | x ^= 10 | x = x ^ 10 |
|= | x |= 10 | x = x | 10 |
Operator | Operations | Example |
< > <= >= == != | Less than Greater than Less than or equal to Greater than equal to Equal to Not equal to | x<y x>y x<=y x>=y x=y x!=y |
Operator | Description |
++ | increments the value by 1. There is post-increment and pre-increment operators |
— | decrements the value by 1. There is post decrement and pre decrement operators |
! | invert a boolean value |
byte
, short
, int
and long
) to perform bit-level operations.These operators are not commonly used. The following types of bitwise operators are available in Java.|
.|
operator compares corresponding bits of two operands. If either of the bits is 1, it gives 1. If not, it gives 0. &
.&
operator compares corresponding bits of two operands. If both bits are 1, it gives 1. If either of the bits is not 1, it gives 0. ~
.~
operator inverts the bit pattern. It makes every 0 to 1, and every 1 to 0.