import java.io.*; import java.lang.*; class BitwiseDemo { public static void main(String args[]) { byte x,y; x=10; y=20; System.out.println("~x= "+(~x)); 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>>2= "+(x>>2)); System.out.println("x<<2= "+(x<<2)); System.out.println("x>>>2= "+(x>>>2)); } }
OUTPUT:
Compile :javac BitwiseDemo.java Run :java BitwiiseDemo ~x= -11 x&y= 0 x|y= 30 x^y= 30 x>>2= 2 x<<2= 40 x>>>2= 2