com.xu.operator.Demo06
作者:互联网
package com.xu.operator;
public class Demo06 {
public static void main(String[] args) {
/*
A=0011 1100;
B=0000 1101;
A&B=0000 1100 //A与B,结果为0000 1100
A|B=0011 1101
~B =1111 0010 //非B,即取反,结果为0000 1100
A^B=0011 0001 //A异或B,如果两个位置相同为0,否则为1;
2*8=16,怎么运算最快;
<< 箭头指向左边,叫左移,相当于*2,>>箭头指向右边,叫右移;相当于/2
0000 0000 0
0000 0001 1
0000 0010 2
0000 0011 3
0000 0100 4
0000 1000 8
0001 0000 16
*/
System.out.println(2<<3);//16
//位运算效率极高,和地层打交道,和二进制打交道;
}
}
\Desktop\JavaSE\out\production\基础语法" com.xu.operator.Demo06
16
Process finished with exit code 0
标签:0000,0001,0011,Demo06,1100,operator,com,xu 来源: https://www.cnblogs.com/xunzhao26/p/14802843.html