9.29

括号的运算优先级最高。同等级运算符在前优先级高。

逻辑非!的运算优先级高于逻辑与&& 和逻辑或||

逻辑与&&的运算优先级高于逻辑或||

package nothh;

public class X为奇数还是偶数 {
    public static void main(String[] args){
    int x = 31;
    int a;
    
        if (x % 2 == 1)
        {
            System.out.println("x是奇数");
        }
        else
        {
            System.out.println("x是偶数");
        }
    //比较运算符无需进行三元运算符的真假比较键入  ?true : false
    boolean b = 20 < 30;
        System.out.println("20 < 30 = " + (20 < 30));


    }
}
 
原文地址:https://www.cnblogs.com/shadowduke/p/4846880.html