See the following expressions in Java.
int temp = -254; Integer temp2 = (Integer) temp; // compiles because of autoboxing Integer temp3 = (Integer) -254; // doesn't compile - illegal start of type. Integer temp4 = (Integer) 10-254; // compiles Integer temp5 = (Integer) (int) -254; // compiles Integer temp6 = -254; // compiles Integer temp7 = (int) -254; // compiles
In the above expressions, why are these expressions (Integer) 10-254 and (int) -254 valid, while the expression (Integer) -254 not compiled, although the constant -254 can be perfectly evaluated to Integer ?
source share