Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Ambiguous varargs

PatchaFeb 21 2012 — edited Feb 24 2012
Hi all!
I have a series of method with same names, but which accept different type of varargs... which means the series of primtiives types and gerical type <T>.

The problem is that they generate "ambiguity" erros when building java code... how's that possible?
Shouldn't be Java smart enough to understand that a "*method(0.0f);*" call have to point to "*method(float... f)*" and not to "*method(double... d)*" or worse "*method(T... t)*"?
Even "*method(char... c)*" generates ambiguity with "*method(double... d)*"!!!

This really disappointed me.
There is something I can do, other than giving different name to each method?

Edited by: EJP on 22/02/2012 08:45: fixed typo in title
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 23 2012
Added on Feb 21 2012
33 comments
918 views