无论如何,有没有要让程序说出哪个条件正确?
public static void main(String[] args) throws IOException, InterruptedException {
Boolean a = true;
Boolean b = false;
Boolean c = null;
if (a == true || b == false || c == true) {
System.out.println("Test");
}
}
既然a
是唯一正确的,有没有办法使它打印出来"a is the only condition that is correct"
if (a) {
System.out.println("a is the condition that is correct");
}
//Edit by comment. Thanks
if (!b) {
System.out.println("b is the condition that is correct");
}
if (c) {
System.out.println("c is the condition that is correct");
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句