Tutorial by Examples

void doSomething(String... strings) { for (String s : strings) { System.out.println(s); } } The three periods after the final parameter's type indicate that the final argument may be passed as an array or as a sequence of arguments. Varargs can be used only in the final argume...
Using varargs as a parameter for a method definition, it is possible to pass either an array or a sequence of arguments. If a sequence of arguments are passed, they are converted into an array automatically. This example shows both an array and a sequence of arguments being passed into the printVar...

Page 1 of 1