String… Parameter in Java
•
Java
See the English answer > varargs and the '...' argument 3
public void method(String... strs);
What does "..." mean? It looks like I need to call the same method with a single string actual parameter, and multiple string actual parameters
Java has no optional parameters (as far as I know), so I'm a little confused here
Solution
It's called varargs; http://docs.oracle.com/javase/6/docs/technotes/guides/language/varargs.html
This means that you can pass any number of parameters (even zero) to the method
In this method, the parameters will be automatically put into the array of the specified type for accessing each parameter
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码