逻辑运算符,与或非
public class Demo05 {
public static void main(String[] args) {
// 与and,或or,非not
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(d);
System.out.println(c); //c = 5,前面的c<4为false,后面的直接不执行,返回结果false
}
}