I just wrote code with the following structure:
public void method(int x) {
I was pretty surprised that this compiled, and that if I call
method(3);
then he will choose the first. Obviously, in a sense, this is a natural choice, but if the first method does not exist, this would be a reasonable way to call the second (with an empty varargs array). So this should be considered ambiguous and produce a compile-time error?
Or is it considered as a special case?
It seems wrong to consider this as such, because it means that adding a new method can break existing code, and this is not a very happy state of affairs.
("Only good" knows which one you are calling if the first was added as a new subclass method containing the second ...)
source share