• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

WIden, Box, Var-arg order of priority

 
Jia Ramharai
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Himai Minh
Ranch Hand
Posts: 1316
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sa IS-A Object, but it IS-NOT-A Integer.
An Object IS-NOT Integer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic