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 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM