I have a method with the following signature:
public void foo(String... params);
So all of these calls are valid:
foo("Peter", "John");
foo(new String[] { "Peter", "John" });
But why is this one not valid?
foo("Peter", new String[] { "John" });
From the docs:
The three periods after the final parameter's type indicate that the final argument may be passed as an array or as a sequence of arguments.
You can't pass an argument and an array.
That's because in fact you try to pass Array containing String and another Array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With