Java Basic Operators: Bitwise Operators and Assignment Operators

Bitwise Operators and Usage

Operator How to use Explanation
>> op1 >> op2 Shift op1 right by op2
<< op1 << op2 Shift op1 left by op2
>>> op1 >>> op2 Op1 is shifted to the right by op2 while the left is always filled with zeros regardless of sign
& op1 & op2 Bitwise logical AND(AND)
| op1 | op2 Bitwise OR(OR)
^ op1 ^ op2 Bitwise exclusive OR (XOR)
~ ~op Bitwise complement number

Assignment Operators and Usage

Operator How to use Explanation
+= op1 += op2 op1 = op1 + op2
-= op1 -= op2 op1 = op1 – op2
*= op1 *= op2 op1 = op1 * op2
/= op1 /= op2 op1 = op1 / op2
%= op1 %= op2 op1 = op1 % op2
&= op1 &= op2 op1 = op1 & op2
|= op1 |= op2 op1 = op1 | op2
^= op1 ^= op2 op1 = op1 ^ op2
<<= op1 <<= op2 op1 = op1 << op2
>>= op1 >>= op2 op1 = op1 >> op2
>>>= op1 >>>= op2 op1 = op1 >>> op2

Share This Post

댓글 남기기

이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다

Latest Post