File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes boxing ,widening,var-args Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "boxing ,widening,var-args" Watch "boxing ,widening,var-args" New topic

boxing ,widening,var-args

vini singh

Joined: Dec 04, 2008
Posts: 18

output: DoX(s,s)=4 doX(7,7)=3

according to me doX(s,s) must be 3 i.e widen and then boxing then why its 4 i.e boxing and then widening.
[edit]Add code tags and disable smilies. CR[/edit]
[ December 06, 2008: Message edited by: Campbell Ritchie ]
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38461
There isn't anything to widen to; the only thing that a short can be boxed to is Number (Short is a subclass of Number).

And please use the code tags; I have added them and you can see how much easier it is to read.
Rob Spoor

Joined: Oct 27, 2005
Posts: 19674

A short can never be converted into an Integer, so all that remains is Short, Number or Object.

You can't widen then box, only box then widen

How To Ask Questions How To Answer Questions
wood burning stoves
subject: boxing ,widening,var-args