[英]Simplify the boolean expression
Here b is a variable of type boolean:这里 b 是一个布尔类型的变量:
(a) b == true
(b) b == false
(c) b != true
(d) b != false
i want to Simplify the following expressions.我想简化以下表达式。
what i had try so far is到目前为止我所尝试的是
a) if (b) a) 如果 (b)
b) b)
c) if (!b) c) 如果 (!b)
You're on your way你在路上
"!= true" = false; “!=真”=假;
"!= false" = true “!=假”=真
(a) b == true
if (b)
(b) b == false
if (!b)
(c) b != true
if (!b)
(d) b != false
if (b)
EDIT: Three answers, all the same and correct.编辑:三个答案,全部相同且正确。 I don't know why one user downvoted them all.
我不知道为什么一位用户对他们全部投了反对票。 The answerer can't help noob-questions being asked here.
回答者无法帮助这里提出的菜鸟问题。
a) if(b)
b) if(!b)
c) if(!b)
d) if(b) (because of double negation, not false is true)
More info about the Java Boolean Condition Logic : http://codingbat.com/doc/java-if-boolean-logic.html有关 Java 布尔条件逻辑的更多信息: http : //codingbat.com/doc/java-if-boolean-logic.html
Have a good day ;)祝你有美好的一天 ;)
I'm not really sure what you're trying to achieve but with what you have given:我不太确定你想要实现什么,但你已经给出了:
(a) b == true
(b) b == false
(c) b != true
(d) b != false
Then you get:然后你得到:
(a) if(b) // Because b is true
(b) if(!b) // Because b is false then the ! (not) operator will give you true.
// You're basically saying "if b is not true then this statement is true"
(c) if(!b) // The assignment say here "b is not true" so therefore: b is false.
// So now you can use the same logic as in (b)
(d) if(b) // Here the assignment says "b is not false" therefore: b is true.
// So now you use the same logic as i (a)
Hope this is what you were going for.希望这就是你想要的。 Next question you ask here should be explained a little more thoroughly :)
你在这里问的下一个问题应该更彻底地解释一下:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.