From this question SO and above, the answers associated with the arithmetic operator + , both operands are converted to type int .
byte b1 = 1; byte b2 = 2; byte b3 = b1 + b2;
In the above code, the values ββof b1 and b2 will be resolved at run time, so the compiler will convert both values ββto int before resolving the value.
But if we look at the following code,
final byte b1 = 1; final byte b2 = 2; int b3 = b1 + b2;
b1 and b2 are final variables, and the values ββwill be resolved at compile time, so compilation will not end.
Not a bug Jan 17 '14 at 13:25 2014-01-17 13:25
source share