Leo*_*nne 0 java boolean return ternary operator-keyword
不是三元运算符假设像arg一样工作?真假 ???所以如果持续时间和石油超过规定的数量而不是字段变量,它应该返回true ..但是这会返回false
public class test12 {
int duration = 260;
int petroleum = 300;
boolean result;
public void checktrain(){
boolean result = duration>=250 && petroleum>=235? true : false;
this.result = result;
}
public void run(){
System.out.print(result);
}
public static void main(String args[]){
test12 tr = new test12();
tr.run();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
120 次 |
| 最近记录: |