posted 17 years ago
No it can't.
The reason it can accept the int literal is that at compile-time the value of the int literal is known, and it is known that the value is compatible with a byte.
However, since the compiler does not carry out the addition, it cannot know what the value of the result will be. Therefore, it can't assign the value to a byte.
Consider this.
byte b = 1;
b = b + 1; // The compiler knows the result is an int,
// but it doesn't know if the result is
// compatible with a byte.
Notice that the following line is seen exactly the same by the compiler as the first addition.
b = b + 1000;