• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AutoBoxing

 
Balaji Bang
Ranch Hand
Posts: 182
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


//Fails To Compile

Why Autoboxing is not done here???
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you expect the method (Integer , Integer) to be called ?
 
Rafael Angarita
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • 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 Java VI Editor
  • Mark post as helpful
  • send pies
  • 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)
 
Ruben Soto
Ranch Hand
Posts: 1032
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic