class TestBit{ public static void main(String[] args){ int i1 = 31; System.out.println(i1<<3);//248 System.out.println(i1<<28); System.out.println(i1>>2);//7 System.out.println(i1>>>2);//7 int i2 = -31; System.out.println(i2>>2);//-8 System.out.println(i2>>>2);//1073741816 System.out.println(12 & 5);//4 System.out.println(12 | 5);//13 System.out.println(12 ^ 5);//9 System.out.println(~12);//-13 } }
输出结果:
248
-268435456
7
7
-8
1073741816
4
13
9
-13