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,776
  • 7
  • 34
  • 45

4 Answers4

7

It's called varargs

Ikke
  • 99,403
  • 23
  • 97
  • 120
3

Wikipedia says this is called a variadic function.

waxwing
  • 18,547
  • 8
  • 66
  • 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,835
  • 5
  • 27
  • 34