The method is ambiguous for the type compiler error
Code below illustrated couse of The method is ambiguous for the type compiler error.
public class AmbiguousMethodOwner {
void ambiguousMethod(Comparable c){}
void ambiguousMethod(Serializable c){}
void test() {
ambiguousMethod("bar");
}
}
The problem now is obvious: since String implements both Comparable and
Serializable, the compiler cannot know which method you intend to call.
A simple cast will solve the problem:
ambiguousMethod((Comparable)"bar");
No related posts.























