3

Given the following methode signature, what does the ... syntax mean?

void acceptAll(Object... all);

i've googled for it, but couldn't find a good explanation for this strange syntax. Can someone give a KISS explanation and a short example?

Gewure
  • 1,190
  • 15
  • 30

2 Answers2

3

These are called the variable arguments or multiple arguments. With this syntax it means the acceptAll methods accept multiple arguments of type Object.

Check Oracle docs here https://docs.oracle.com/javase/8/docs/technotes/guides/language/varargs.html

saurav
  • 4,722
  • 9
  • 47
  • 87
2

It's a Variadic function, which means it can take a variable number of arguments (hence the other name, a varargs function). In the body, the variable indicated by ... is treated like an array.

Elliott Frisch
  • 191,680
  • 20
  • 149
  • 239