7

Possible Duplicate:
What is the ellipsis for in this method signature?

For example: protected void onProgressUpdate(Context... values)

Community
  • 1
  • 1
Eugene
  • 59,186
  • 91
  • 226
  • 333

6 Answers6

9

One word: varargs.

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.

Matt Ball
  • 354,903
  • 100
  • 647
  • 710
5

They're called varargs, and were introduced in Java 5. Read http://download.oracle.com/javase/1.5.0/docs/guide/language/varargs.html for more information.

In short, it allows passing an array to a method without having to create one, as if the method took a variable number of arguments. In your example, the following four calls would be valid :

onProgressUpdate();
onProgressUpdate(context1);
onProgressUpdate(context1, context2, context3);
onProgressUpdate(new Context[] {context1, context2});
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
2

Its the varargs introduced in java 5. more info at Varargs

Manoj
  • 5,542
  • 9
  • 54
  • 80
0

Three dots are called ellipsis. Method can be called any number of values of type Context. You can call that method with no value also.

yogsma
  • 10,142
  • 31
  • 97
  • 154
0

It means that the values argument is an optional array of Context objects. So you could call the "onProgressUpdate" function in the following ways:

onProgressUpdate(); // values is an empty array.
onProgressUpdate(new Context[] { new Context() }); // values has one item.
onProgressUpdate(context1, context2); // values has two items.

See the varargs language feature introduced in Java 1.5.

maerics
  • 151,642
  • 46
  • 269
  • 291
0

That means that you can put a range of values :

onProgessUpdate(c1,c2,c3);
Zakaria
  • 14,892
  • 22
  • 84
  • 125