KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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 ?
Tags (comma-separated)
Save Edits
Cancel