String... parameter in Java
It's called varargs; http://docs.oracle.com/javase/6/docs/technotes/guides/language/varargs.html
It means you can pass an arbitrary number of arguments to the method (even zero).
In the method, the arguments will automatically be put in an array of the specified type, that you use to access the individual arguments.
It's called an ellipsis and it means the method can take multple String
s as its argument.
See: The Java tutorial on passing arguments on Oracle's site.
See java optional parameters : as of Java 5, Java has support for variable numbers of arguments.
Yes, that means you can take arbitrary no of Strings as an argument for this method.
For your method:
public void method(String... strs);
You can call it as:
method(str)
method(str1, str2)
method(str1,str2,str3)
Any no of arguments would work. In other words, it is a replacement for:
public void method(String[] str);