Java method with unlimited arguments

It’s called varargs.

It allows a method to take any number of arguments. They are accessible as an array in the method:

public void foo(String... args) {
    for (String arg : args) {
      // do smth with arg.
     }
}

This is syntactic sugar. The compiler hides the array creation, so instead of

 bar.foo(new String[] {"1", "2", "3"});

you write

 bar.foo("1", "2", "3");

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)