Forums Register Login

WIden, Box, Var-arg order of priority

+Pie Number of slices to send: Send
Hello All,
I came across the piece of code below and could not understand the output for line 15:



The compiler compiles and outputs 212.
2 - x is boxed to Integer and then widened to Object.
y is widened to Object.
1 - x is boxed to Integer and then widened to Object.
2 - ???

Can someone please explain what happens for the last 2 to be output instead of 3?

Thank you.
+Pie Number of slices to send: Send
sa IS-A Object, but it IS-NOT-A Integer.
An Object IS-NOT Integer.
F is for finger. Can you stick your finger in your nose? Doesn't that feel nice? Now try this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 902 times.
Similar Threads
Advanced overloading
Method overloading
Widening and boxing doubt
code explanation needed
Advanced Overloading (widening,boxing,var args)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 09:00:32.