Java main methods with "..." arrays?

arrays, ellipsis, java, string, variadic-functions

Solution

That's a notation from Java 5 for variable length argument lists. It is roughly equivalent to a String array, but lets you pass individual parameters that are combined into an array automatically.

void mymethod(String... a) {
    for (String s : a) {
        ...
    }
}

mymethod("quick", "brown", "fox");

This makes sense only when you plan to call a method from your program, so I do not see why it would be desirable to use this syntax for your main(). It will work, however.

Problem

Possible Duplicate: What is the ellipsis (…) for in this method signature? java: how can i create a function that supports any number of parameters? well i'm trying to figure out some examples and I found this kind of array definition for arguments in the main method. What's so special about this "..." and what's the difference between a normal String[] args? Thanks

Original source

Related problems