Just trying to understand auto-boxing, which I do apart from one thing:
Short s = 250;
Long l = 250;
The assignment to Long l
fails. This, I expect, is because you cannot widen then box (i.e. it tries to widen the int
value 250
to a long
and then box it which it cannot do).
However, the assignment to Short s
works. What is going on to make this fine? My assumption was it is still doing boxing and some kind of conversion. But if it's a case of it knowing 250
fits into a short
, why does it not know that 250
will fit into a long
?
fail for Long
? – Derosierint
toLong
. – Tallis