运算符优先级

来源:互联网 发布:常见软件生命周期模型 编辑:程序博客网 时间:2024/06/08 07:59

口诀:成员括号,单目四则,移位关系,位与逻辑,条件赋值

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package test;/** * * @author huanghuankun */public class OprPriority {    //运算符优先级:成员括号,单目四则,移位关系,位与逻辑,条件赋值    public static void main(String[] agrs) {        int i = 6;        int j = 8;        int m = 7;        int k = 10;        if (!(i > j ^ m > k++)) {            k++;        }        System.out.println("i > j ^ m > k++ ="+(i > j ^ m > k++));        System.out.println("k=" + k);    }}

输出结果:

i > j ^ m > k++ =false
k=13


0 0