| 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
|
|
|
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
|
|
Jacob Sonia wrote:So you mean character can be automatically casted to int, float etc
Yes
|
 |
 |
|
|
subject: Overloading problem
|
|
|