• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

boxing ,widening,var-args

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic