aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "boxing ,widening,var-args" Watch "boxing ,widening,var-args" New topic
Author

boxing ,widening,var-args

vini singh
Greenhorn

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
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
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
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: boxing ,widening,var-args
 
Similar Threads
boxing
Widening beats boxing?
Boxing & Widening
Question on widening ,boxing
Another question about Widening and Boxing