逻辑运算符,位运算符
逻辑运算符
package operator;//逻辑运算符
public class Demo05 {public static void main(String[] args) {//与  或  非boolean a=true;boolean b=false;System.out.println("a&&b:"+(a&&b));//逻辑与,两个变量都为真,结果为真System.out.println("a||b:"+(a||b));//逻辑或,两个变量有一个为真,结果为真System.out.println("!(a&&b):"+(!(a&&b)));//如果真就为假,如果为假就为真//短路运算int c=5;boolean d=(c<4)&&(c++<4);System.out.println(c);System.out.println(b);}
}位运算符
package operator;//位运算符
public class Demo06 {public static void main(String[] args) {/*A=0011  1100B=0000  1101A&B= 0000 1100A|B= 0011 1101A^B= 0011 0001~B = 1111 00102*8=16   2*2*2*2<< *2>>/20000 0000  00000 0001  10000 0010  20000 0011  30000 0100  40000 1000  80001 0000  16* */System.out.println(2<<3);}
}