Search code examples
javafunctionparametersprototypenotation

In Java, what does the notation `...` mean in the context of a prototype declaration: `type function_name (type... parameter_name)`


I'm learning Java, and in function prototypes I often see parameters of the variety type... parameter_name. What does the ... notation mean?


Solution

  • The New Features and Enhancements J2SE 5.0 says (in part)

    Varargs

    This facility eliminates the need for manually boxing up argument lists into an array when invoking methods that accept variable-length argument lists. Refer to JSR 201.

    It's also called a variadic function. Per the wikipedia,

    In computer programming, a variadic function is a function of indefinite arity, i.e., one which accepts a variable number of arguments.