# Widening and boxing

J Brewer

Ranch Hand

Posts: 46

posted 9 years ago

I ran the following code,

and I got the same answer as the book, 4 3. However, I don't understand why

the answer is not 3 3. Since s is of type Short, couldn't you box short to Short, then widen Short to Integer? The only answer I can think of is maybe because Short is now an object not a primitive, it is a subclass of Number, not Integer? Is that correct?

and I got the same answer as the book, 4 3. However, I don't understand why

the answer is not 3 3. Since s is of type Short, couldn't you box short to Short, then widen Short to Integer? The only answer I can think of is maybe because Short is now an object not a primitive, it is a subclass of Number, not Integer? Is that correct?

Stephen O'Kane

Greenhorn

Posts: 26