[Solved] Method Overloading – Java


It will call (1) because the method resolution algorithm gives priority to methods that do not use varargs.

To force it to use (2) you can pass an array or cast the first parameter to Object:

myMethod(new Object[] { "name", new MyClass() });
//or
myMethod((Object) "name", new MyClass());

1

solved Method Overloading – Java