2

I have noticed in Java that you can have a function with object... as a parameter and then method will take any number of objects as a parameter and treat it as an array. What is this called? I have been trying to search for it but it seems ... is ignored by search engines. I seem to remember printf in C does the same thing.

Thanks.

A Jackson
  • 2,596
  • 7
  • 34
  • 43

4 Answers4

7

It's called varargs

Ikke
  • 95,379
  • 23
  • 93
  • 119
3

Wikipedia says this is called a variadic function.

waxwing
  • 18,172
  • 8
  • 63
  • 82
2

It's called varargs

1

It's called varargs.

It means is function is accepting variable number of arguments. In C/CPP there is a header file stdarg.h which have declaration of methods for handling variable arguments.

GG.
  • 2,687
  • 5
  • 25
  • 33