File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes WIden, Box, Var-arg order of priority Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "WIden, Box, Var-arg order of priority" Watch "WIden, Box, Var-arg order of priority" New topic
Author

WIden, Box, Var-arg order of priority

Jia Ramharai
Greenhorn

Joined: Feb 21, 2013
Posts: 5
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

Joined: Jul 29, 2012
Posts: 734
sa IS-A Object, but it IS-NOT-A Integer.
An Object IS-NOT Integer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: WIden, Box, Var-arg order of priority