How does the Java array argument declaration syntax “…” work?

I believe this was implemented in Java 1.5. The syntax allows you to call a method with a comma separated list of arguments instead of an array.

public static void main(String... args);
main("this", "is", "multiple", "strings");

is the same as:

public static void main(String[] args);
main(new String[] {"this", "is", "multiple", "strings"});

http://today.java.net/article/2004/04/13/java-tech-using-variable-arguments
http://download.oracle.com/javase/1.5.0/docs/guide/language/varargs.html

Leave a Comment