classBitwiseTest { publicstaticvoidmain(String[] args) { // Test << inta=1; System.out.printf("Binary of 1:%s\n", Integer.toBinaryString(a)); a <<= 1; System.out.printf("Binary of 1<<1:%s\n\n\n",Integer.toBinaryString(a));
// Test >> intb=2; System.out.printf("Binary of 2:%s\n", Integer.toBinaryString(b)); b >>= 1; System.out.printf("Binary of 2>>1:%s\n\n", Integer.toBinaryString(b));
// Test >>> with positive integer intc=2; System.out.printf("Binary of 2:%s\n", Integer.toBinaryString(c)); c >>>= 1; System.out.printf("Binary of 2>>>1:%s\n\n", Integer.toBinaryString(c));
// Test >>> with negtive integer intd= -1; System.out.printf("Binary of -1:%s\n", Integer.toBinaryString(d)); d >>>= 1; System.out.printf("Binary of -1>>>1:%s\n\n", Integer.toBinaryString(d)); } }