java中关于'&&'、'||'混合运算优先级问题小结

 1 package com.per.sdg.operator;
 2 /**
 3  * 结论:先进行'&&'运算,在进行'||'运算
 4  * @author sundg
 5  *
 6  */
 7 public class AndOrDemo {
 8     public static void main(String[] args) {
 9         int a=1;
10         int b=3;
11         int c=5;
12         boolean d=true;
13         System.out.println(a>b||c>b&&d);//==>F||T&&T==>T
14         System.err.println(b>a||a>c&&d);//==>T||F&&T==>T
15         System.out.println(a>b||c>b&&false);//==>F||T&&F==>F
16         System.out.println(b>a||c>b&&false);//==>T||T&&F==>T
17         
18     }
19 }

 

posted @ 2018-03-23 10:56  根须  阅读(5661)  评论(0)    收藏  举报