If I have two methods with the same signature, varying only by vararg type, how does Java know which one to call when I use no parameter or pass null?
For example, if I have these two methods:
public static String test(String a, String b, Object... args){
return "object args";
}
public static String test(String a, String b, String... args){
return "string args";
}
And I call:
System.out.println(test("a", "b"));
System.out.println(test("a", "b", null));
The output is "string args". Why does Java decide to call the 2nd method here instead of the first one? I had a hard time finding the relevant portion of the specification that describes this.