java中的逻辑运算符 [英] logical operators in java

查看:129
本文介绍了java中的逻辑运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

一个明确的,外行人对...之间差异的解释和||在c#?

有什么区别|和||在Java?

运算符之间有什么区别?和运营商|| ??
和&之间的区别是什么?和&& ??

what is the difference between the operator | and the operator || ?? and also what is the difference between & and && ??

谢谢......

推荐答案

主要区别在于在表达式 a&&如果 a 为false,则不会评估b b ,而在 a& b 无论如何都将评估 a b 。可以说&& 短路评估。

The main difference is that in an expression a && b, b will not be evaluated if a is false, while in a & b both a and b will be evaluated no matter what. One can say that && "short-circuits" the evaluation.

类似地,对于 a || b b 如果 a 为真,则不会被评估,而在 a | b 无论如何都将评估 a b

Similarly for a || b: b will not be evaluated if a is true, while in a | b both a and b will be evaluated no matter what.

这篇关于java中的逻辑运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆