class BitTest { public static void main(String[] args) { int m = 12; int n = 5; System.out.println("m & n :" + (m & n)); System.out.println("m | n :" + (m | n)); System.out.println("m ^ n :" + (m ^ n)); } }
//1&1=1 否则0
//0|0=0 否则1
//1^1=0 0^0=0 1^0=1 0^1=1
运行结果:
m & n :4
m | n :13
m ^ n :9