Bitwise operators in java only for integer and long?

Viewed 3989

I wrote following code in Eclipse:

byte b = 10;
/* some other operations */
b = ~b;

Eclipse wanted a cast to byte in the line of the bitwise complement. It said: "Type mismatch: cannot convert from int to byte". I also tried this with other bitwise operations and on other integral types. It was with short and char the same. Only long and integer could use bitwise operations.

Is there a reason for this?

2 Answers
Related