aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Overloading  problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Overloading  problem" Watch "Overloading  problem" New topic
Author

Overloading problem

Jacob Sonia
Ranch Hand

Joined: Jun 28, 2009
Posts: 164
Hi, Can anybody explain the reason of ambiguity here.

Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9191
    
    2

Hint: char can be automatically upcasted to float...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Prithvi Sehgal
Ranch Hand

Joined: Oct 13, 2009
Posts: 771


First thing i suppose that var-args are the last choice made by the compiler. In your case, if your see there is already a more specific method
present that is number 1 which takes a float. Now when you try to invoke the method calls from your main method, in your second call, as Ankit
told character is automatically up-casted to float then the compiler gets confused, which method to call as there is already a more specific method
present. Thats why it gives the ambiguity error. Hope this helps.


Prithvi/Beenish,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup
Jacob Sonia
Ranch Hand

Joined: Jun 28, 2009
Posts: 164
So you mean character can be automatically casted to int, float etc
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9191
    
    2

Jacob Sonia wrote:So you mean character can be automatically casted to int, float etc

Yes
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Overloading problem
 
Similar Threads
method local inner class doubt
TOTALLY CONFUSED.......PLEASE HELP
how come its compiling??
How to make this Possible..Pls help
conversion Doubt