Proper terminology for Object... args

SnakeDoc picture SnakeDoc · May 21, 2013 · Viewed 22.4k times · Source

I'm working in Java and the typical way you specify multiple args for a method is:

public static void someMethod(String[] args)

But, I've seen another way a few times, even in the standard Java library. I don't know how to refer to this in conversation, and googling is not of much help due to the characters being used.

public static void someMethod(Object... args)

I know this allows you to string a bunch or arguments into a method without knowing ahead of time exactly how many there might be, such as:

someMethod(String arg1, String arg2, String arg3, ... etc

How do you refer to this type of method signature setup? I think it's great and convenient and want to explain it to some others, but am at a lack of how to refer to this. Thank you.

Answer

Keppil picture Keppil · May 21, 2013

This way to express arguments is called varargs, and was introduced in Java 5.
You can read more about them here.