When this code is executed, I get a compile time error -
byte b = 50;
b = b * 2;
Error -
incompatible types: possible lossy conversion from int to bye
I am aware of the fact that Java automatically promotes byte to int during compilation.
Then why does the following code doesn't produce any error and runs fine -
byte b = 50;
b *= 2;
Isn't b = b * 2
and b *= 2
the same?