In the following fragment, is the & a bitwise or logical operator? why?
boolean a, b;
//
if (a & b)...
If you regard booleans as single-bit numbers, then &
on booleans is consistent with a bitwise operation.
Java regards true and false as logical values, not numbers, so I would say that &
on booleans is a logical operator, not a bitwise operator. But people often refer to it as "bitwise &", to distinguish it from &&
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.