-1
public static void main (String... arg)

I have never encountered the ... part in the function definition. Could anyone give some insight into this notation?

Pshemo
  • 122,468
  • 25
  • 185
  • 269

1 Answers1

3

The ... indicates that you are passing 0 or more arguments of the type and the method will access them as an array of objects of the type. You may pass them as an array or as a sequence of objects of the declared type. I.e.:

In your main method use

String firstArg = arg[0];

to access the first argument.

Look at the documentation of varargs for more info.

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
Brian Hibbert
  • 250
  • 2
  • 8