Murat Kutluer wrote:Do you have any idea why test2 compiles but test3 does not?
Murat Kutluer wrote:The trick is compile-time constant.
Murat Kutluer wrote:What about this one? Both int and long are larger primite than short, but int works, long doesn't.
In addition, if the expression is a constant expression (§15.28) of type byte, short, char, or int:
* A narrowing primitive conversion may be used if the type of the variable is byte, short, or char, and the value of the constant expression is representable in the type of the variable.
Henry Wong wrote:Regarding the second question... variable assignment conversions is simply defined by section 5.2 of the JLS. No need to give further detail here...