Varargs was added in Java 5 and the syntax includes three dots … (also called ellipses)

Varargs was added in Java 5 and the syntax includes three dots … (also called ellipses)

Following is the syntax of vararg method.

public void testVar(int count, String... vargs) { }

String.. .   actualy is a list of String.

You may use for(String s : vargs) to iterate through it.

Mainly used in Reflection API, when you do not know exactly how many parameters of a method has.

你可能感兴趣的:(Varargs was added in Java 5 and the syntax includes three dots … (also called ellipses))