I want overload two method with one parameter, in a method varargs of String and another String[] but I achieve following compilation-time error:
Duplicate method registerByName(String...)
My snippet code is:
public void registerByName(String[] names)
{
}
public void registerByName(String...names)
{
}
Why?
varargis another way to place(Object[])so a MethodMyMethod(MyObject[] obj)andMyMethod(MyObject... obj)are the same to compiler. It’s just syntactic sugar.You could refer the doc