如何在 Java 中制定 NOR 运算符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11765530/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to formulate the NOR operator in Java
提问by user1510230
I was just wondering how can get the NOR operator in Java like this
我只是想知道如何在 Java 中像这样获得 NOR 运算符
if (!(foo == "bar" || foo1=="bar1")){
...
}
Edit : I was looking for a more efficient way to write that
编辑:我正在寻找一种更有效的方式来写
回答by aioobe
[...] I was looking for a more efficient way to write that
[...]我正在寻找一种更有效的方式来写
There is no NOR operator in Java. You have to do it as you've done
Java 中没有 NOR 运算符。你必须像你所做的那样做
!(A || B)
or, !A && !B
of course.
或者,!A && !B
当然。