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,208
  • 18
  • 31

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
  • 5,388
  • 10
  • 56
  • 101
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
  • 198,278
  • 20
  • 158
  • 249