1

Possible Duplicates:
Java array argument “declaration” syntax
What is the ellipsis for in this method signature?

I've stumbled upon a function that has a String... strings as a parameter. What is the significance of this? I'm assuming it means any number of string arguments but isn't that the point of List?

function doStuff(String... strings) {
    //Code
}

I'd appreciate an explanation of its purpose and usage in applications. Thanks

Community
  • 1
  • 1
Spidy
  • 39,723
  • 15
  • 65
  • 83
  • 3
    Try [this](http://stackoverflow.com/questions/5504260/what-does-mean-in-java) question or [this](http://stackoverflow.com/questions/4618930/what-does-mean-in-java) or [this](http://stackoverflow.com/questions/4211099/java-array-argument-declaration-syntax) – Shaded Apr 27 '11 at 19:19
  • 1
    This question was just asked earlier today *and* closed as a duplicate. – Jeremy Apr 27 '11 at 19:21
  • There is no keyword 'function' in Java. Do you mean 'public [static] [void|int|String|Object|...]? – user unknown Apr 27 '11 at 19:32

2 Answers2

1

I is the syntax for specifying varargs i.e. specifying that a method can take a variable number of arguments.

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.

aioobe
  • 413,195
  • 112
  • 811
  • 826
0

It's the Ellipsis. It allows varargs, see:

What is the ellipsis (...) for in this method signature?

Community
  • 1
  • 1
MarkPowell
  • 16,482
  • 7
  • 61
  • 77