In the following fragment, is the & a bitwise or logical operator? why?
boolean a, b;
//
if (a & b)...
CodePudding user response:
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 &&
.