byte b=5; Integer i=(int)b;//b cast to int and int wrapped into Integer Integer k=(byte)b;//compilation error, cannot convert from byte to Integer Integer z=(byte)5;//compiles
My question is: why does Integer z=(byte)5 compile, but Integer k=(byte)b does not? In this case, Integer z1 = (byte)5L and Integer z2 = (byte)5.3F also compiled. Is it because I'm trying to set a compile-time constant, and the cast does not affect it?
source share