File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes AutoBoxing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "AutoBoxing" Watch "AutoBoxing" New topic
Author

AutoBoxing

Balaji Bang
Ranch Hand

Joined: Apr 23, 2007
Posts: 180


//Fails To Compile

Why Autoboxing is not done here???
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

Do you expect the method (Integer , Integer) to be called ?
Rafael Angarita
Ranch Hand

Joined: Jan 09, 2009
Posts: 67
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)


Rafael Angarita.
SCJP 6.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



//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

Joined: Dec 16, 2008
Posts: 1032
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.


All code in my posts, unless a source is explicitly mentioned, is my own.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: AutoBoxing
 
Similar Threads
Clarification with Overloading and varargs usage
Autoboxing and initialization of non-instance variables (Need cameron's permission)
BETA: Method resolving, un/boxing varargs mock question
Boxing Doubt
Autoboxing & API :-D