Java bitwise operators

//program to demonstrate bitwise operators


//bitwise operators in java



import java.io.*;
public class Bitwise
{
public static void main(String s[])
{
int x=10,y=2;
System.out.println("Value of x= "+x+" Value of y="+y);
System.out.println("x>>2: "+(x>>2));
System.out.println("x<<2: "+(x<<2));
System.out.println("x>>>1: "+(x>>>1));
System.out.println("x&y: "+(x&y));
System.out.println("x|y: "+(x|y));
System.out.println("x^y: "+(x^y));
System.out.println("~x: "+(~x));
}
}

Output



java bitwise operators
Java bitwise operators


No comments: