Java逻辑运算符
public class Demo04 {
public static void main(String[] args) {
boolean a = true;
boolean b = false;
System.out.println("a && b: "+(a && b));//与运算:两个变量都为真,结果才为true
System.out.println("a || b: "+(a || b));//或运算:两个变量有一个为真,结果才为true
System.out.println("! (a && b): "+!(a && b));//如果是真,则变为假,如果是假则为真
}
}

浙公网安备 33010602011771号