Bitwise & Shift Operators in Java

A shift operator performs bit manipulation on data by shifting the bits of its first operand right or left. The bitwise operators are the operators used to perform the operations on the data at the bit-level. When we perform the bitwise operations, then it is also known as bit-level programming. It consists of two digits, either 0 or 1.

| Bitwise OR
& Bitwise AND
^ Bitwise XOR
~ Bitwise complement
<< Left shift
>> Signed right shift
>>> Unsigned right shift

Source Code

public class Bitwise {
    public static void main(String args[])
        //Bitwise & Shift Operators in Java
        int a=25,b=45;
        System.out.println("Bitwise And : "+(a&b));
        System.out.println("Bitwise Or : "+(a|b));
        System.out.println("Bitwise Xor : "+(a^b));
        System.out.println("Bitwise Not : "+(~a));


Bitwise And : 9
Bitwise Or : 61
Bitwise Xor : 52
Bitwise Not : -26
To download raw file Click Here

Basic Programs