Source:
public class TestVarArgs {
public void varArgsMethod(Object ... arr) {
System.out.println(arr.getClass().getName());
for(Object o : arr)
One of the elegant ways to get rid off this warning:
instead of
tva.varArgsMethod(args)
call
tva.varArgsMethod(Arrays.stream(args).toArray())
explicitly showing that you pass multiple arguments.
Another way to get rid off the warning is to use following call:
tva.varArgsMethod(Arrays.asList(args).toArray())
Anyway we have to convert the args to Array.