This is because String...
will be converted into String[]
According to jls §8.4.1
Invocations of a variable arity method may contain more actual argument expressions than formal parameters. All the actual argument expressions that do not correspond to the formal parameters preceding the variable arity parameter will be evaluated and the results stored into an array that will be passed to the method invocation.
It is a compile time error to declare varargs
in Java like:
String... abc={"abc","def"};
This is because varargs
is available as the last parameter in method signature, and as said in jls, varargs
will be evaluated and result will be stored in array and then passed to method