The ...
signify that the method supports var-args i.e. variable (number of) arguments.
So, you could call your myMethod()
as
myMethod(); // or
myMethod(str1); // or
myMethod(str1, str2); // and so on
using the same method signature myMethod(String... str)
. When declaring a var-arg method with multiple parameters the var-arg parameter must succeed after all other normal method parameters.
Inside the method all the passed arguments become accessible as an array with the same reference name as that of the parameter. So, you can actually use str.length
here.
The feature is quite flexible. You can even pass a String[]
to it. But, the reverse is not true. A method taking an array would not accept individual strings.