Files
javaSE251223/day02/src/com/inmind/Demo10.java

33 lines
1.0 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.inmind;
/*
运算符_逻辑运算符
&& : 双与 短路与 并且
|| :双或 短路与 或者
! : 非 取反
短路效果:双与与双或的短路效果(只要已经有确定的结果,就不要做多余的操作)!!!!!
*/
public class Demo10 {
public static void main(String[] args) {
//双与:一假即假
System.out.println(true && true);//true
System.out.println(true && false);//false
System.out.println(false && true);//false右边不计算
//双或:一真即真
System.out.println(false || false);//falase
System.out.println(false || true);//true
System.out.println(true || false);//true右边不计算
System.out.println(!false);//true
System.out.println("-----------------------------------------------");
int i = 10;
System.out.println(i>5 && i++>10);//false
System.out.println(i);//11
int j = 20;
System.out.println(j++<21 && ++j<20);
System.out.println(j);
}
}