为什么日食说:
"运算符 == 未定义参数类型布尔值,null"
在 if 语句 ?为什么无权写?
Object max;
double a1;
double a2;
if ((max != null && a1 > a2) ¦¦ max == null)
// Something
刚刚测试过,一切都很好,除了那个神秘的¦¦
,使用||
Object max = null;
double a1 = 0;
double a2 = 0;
if ((max != null && a1 > a2) || max == null){
}
日蚀只是困惑地说
The operator == is undefined for the argument type(s) boolean, null
if ( (max != null && a1 > a2) ¦¦ max == null ){
........^........(boolean) , ..null....... (treating that ¦¦ as comma)
}
为了使你的代码能够编译,你只需要在之前初始化变量,并摆脱这个¦¦
- 我想你想使用OR
||
Object max = null;
double a1 = 0;
double a2 = 0;
if ((max != null && a1 > a2) || max == null){}