JAVA logical operators, bit operators

Logical Operators

//&& || !
 与  或  非 
boolean a = true;
boolean b= false;
System.out.println(a&&b);//false
System.out.println(a||b);//true
System.out.println(!(a&&b);//true

//&& 短路运算,即(a&&b) 若a为false则b不执行运算                   

Bit operator

/*
A=00111100
B=00001101
A&B=00001100
A|B=00111101
A^B=00110001(相同为0不同为1)
~B =11110010

2*8 how to calculate the fastest

<<
>> 
System.out.println(2<<3);//16
//<<代表*2  >>代表/2

Very high bit efficiency

Guess you like

Origin blog.csdn.net/qq_33956536/article/details/106463594