Please can anybody explain, I found this in a program on the Internet. I googled it up but nothing helped as I don't know what it is called?
Why are there three dots(...) after String in the argument? Please Explain.
public static void MakePro(String... visual)
{
..
}
Varargs (Variable Arguments) Varargs (introduced in Java SE 5) allows you to pass 0, 1, or more params to a method's vararg param. They let you pass any number of objects of a specific type.This reduces the need for overloading methods that do the similar things. For example,
AsSimpleAsThis(s1,s2,s3); // pass 3 strings
params[0] is the first string
params[1] is the second string
params[2] is the third string
params[0] is the first string (="hello")
params[1] is the second string
params[0] is the first string=hey
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. Varargs can be used only in the final argument position.