我正在學習Java中的運算符,我遇到了一個我無法解決的問題。Java中的運算符
public static boolean first(){
System.out.println("first");
return true;
}
public static boolean second(){
System.out.println("second");
return true;
}
public static boolean third(){
System.out.println("third");
return true;
}
public static void main(String[] args) {
if(first() && second() | third()){
//Do something
}
}
輸出是「第一二三」。我認爲它應該是「第三第一」,因爲|大於& &。我不知道我的錯誤在哪裏,但顯然有一個。
'if(first()&& second()|| third()){' –