public class BooleanTest {
public static void main(String[] args){
boolean b = true;
if(!b){System.out.println("if");}
else{System.out.println("else");}
}
}
这里的输出是 else。 '!'代表不是。那么,“如果不是 b”,这是什么意思:如果 b 不是真/假?
最佳答案
它翻译为“如果b
不为真”。 !
运算符在传递 false
时返回 true
,在传递 true
时返回 false
。
关于java - 我的代码中 if(!b) 的含义是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4688195/