• 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

AutoBoxing

 
Ranch Hand
Posts: 182
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


//Fails To Compile

Why Autoboxing is not done here???
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you expect the method (Integer , Integer) to be called ?
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Compiler error: The method method(int i,Integer k) is ambiguous for the type Boxing()

The problem here is that more that one method match the invocation.

Anyway, I'm waiting for an explanation.

Does this kind of question appear in the real exam? (I'm confused here)

 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



//Fails To Compile

Why Autoboxing is not done here???


It fails because of AutoBoxing.Otherwise it would have thrown nosuch method error. as there is no method (Integer,int)
 
Ranch Hand
Posts: 1032
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rafael Angarita wrote:Compiler error: The method method(int i,Integer k) is ambiguous for the type Boxing()

The problem here is that more that one method match the invocation.

Anyway, I'm waiting for an explanation.

Does this kind of question appear in the real exam? (I'm confused here)


All three methods require boxing/unboxing, so if you have any 2 of those methods declared you will get a compiler error on the method invocation.
reply
    Bookmark Topic Watch Topic
  • New Topic