Java-Bitwise Operators

Bitwise Operators

Java has a distinction of supporting special operators known as bitwise operators for manipulation of data at values of bit level. Bitwise operators can be applied to the interger types, byte, char, short, int and long. Bitwise operators may not be applied to float or double.

Bitwise AND(&)

The bitwise AND operator is represented by a single ampersand (&) and is surrounded on both sides by integer expressions. The result of ANDing operation is 1 if both the bits have a value of 1; otherwise it is 0.



Program Source

public class Javaapp {

    public static void main(String[] args) {
        int a = 10;
        int b = 12;
        int c = a & b;
        System.out.println("Value of c = "+c);

Leave a Comment