I dont understand .. (from A Programmer's Guide to
Java Certification 3rd Edition - mughal pg 172)
a) if this work
Integer iRef3 = (short)10; // constant in range: casting by narrowing to short,
// widening to int, then boxing
b) Exactly as above but instead of Integer .. i use Long. // This doesnt work
Long iRef3 = (short)10;
c) This also doesnt work
short s = 10; // narrowing (a)
Integer iRef1 = s; // short not assignable to Integer -- error here (b)
Since implicit conversion succeded for (a) and you dont need constant expression for widening conversion (b) .. why it doesnt work on (b).
I thought the variable s would be widen to int and then boxing into Integer.
Any help is appreciated