我想thinking in java 里应该解释清楚了吧The boolean type is treated as a one-bit value, so it is somewhat different. You can perform a bitwise AND, OR, and XOR, but you can’t perform a bitwise NOT (presumably to prevent confusion with the logical NOT). For booleans, the bitwise operators have the same effect as the logical operators except that they do not short circuit. Also, bitwise operations on booleans include an XOR logical operator that is not included under the list of “logical” operators. You cannot use booleans in shift expressions, which are described next.
而且boolean是不可以转型的对吧。
var1 = ! var2; 如果var2是false,var1的值就是true,否则为false(逻辑非)
var1 = var2 & var3 如果var2和var3都是true,var1的值就是true,否则为false(逻辑与)
var1 = var2 | var3; 如果var2或var3是true(或两者都是),var1的值就是true,否则为false(逻辑或)
var1 = var2 || var3; 如果var2或var3是true(或两者都是),var1的值就是true,否则为false (逻辑或)
所以基于这点,JavaScript中可以做或运算!
我是说java中 ,虽然题目简单 ,但也要看清楚啊。
if(fig)
{}
else
{
}
可是我问的也不是这个问题啊。
今天来的怎么都是所答非所问啊。
我是支持 boolean其实就是一个bit 但是我解释不清楚,这是其一。
其二,我上面提过,在java中boolean和其它类型是不可以相互转型的,就算jvm也要符合规则。
问题:1.boolean类型为什么可以运算? 2.为什么 或运算结果会是 boolean类型的。