Bitwise & Bit Shift Operators

Bitwise & Bit Shift Operators

The Java Programming Language provides operators that perform bitwise and bit shift operations on integral types.
A bitwise & bit shift operation operates on one or more bit patterns or binary numerals at the level of their individual bits.

Because the Bitwise & Bit Shift Operators are not commonly used in Java programming, we will not spend a lot of time going over their details.

Operator Description
~ inverts a bit pattern
<< shifts a bit pattern to the left
>> shifts a bit pattern to the right
>>> shifts a zero into the leftmost position
& performs bitwise AND operation
^ performs a bitwise exclusive OR operation
! performs a bitwise inclusive OR operation


Bitwise AND Operator Sample

int jcdBitMask = 0x000F;
        
int jcdValue = 0x2222;
       
System.out.println(jcdValue & jcdBitMask);


Bitwise AND Operator Output

2


Now that your done with lesson 6.3, let’s see what you learned with the knowledge check on Java operators.



Add a Comment

Your email address will not be published. Required fields are marked *