A variable arity (aka varargs) method is a method that can take a variable number of arguments. The method must contain at least one fixed argument. When processing a varargs variable arity method call, the Java compiler checks the type types of all arguments, and all of the variable actual arguments to each variable arity method to ensure that they match the arguments in the method definitionmust match the variable formal argument type. However, the compile-time type checking is ineffective when Object
or generic parameter types are used [Bloch 2008]. The presence of initial parameters of specific types is irrelevant; the compiler will remain unable to check Object
or generic variable arity parameter types. Enable strong compile-time type checking of variable arity methods by using the most specific type possible for the type of the method parameter.
...