逻辑运算符
package operator;
//逻辑运算符
public class Demo4 {
public static void main(String[] args) {
//与(两个都要要and) 或(其中一个or) 非(非你即我 取反的意思)
boolean a = false;
boolean b = true;
System.out.println("a && b:"+(a&&b));//逻辑与运算
System.out.println("a || b:"+(a||b));//逻辑或运算
System.out.println("!(a && b):"+ !(a&&b));//逻辑非运算
/*短路运算在逻辑与(&&)和逻辑或(||)运算中,
当计算结果可以提前确定时,就不会再计算剩余的表达式*/
int f = 3;
boolean d = (f>0) && (f++ <4);
System.out.println(d);
System.out.println(f);
}
}