Java "params" in method signature?

This will do the trick in Java

public void foo(String parameter, Object... arguments);

You have to add three points ... and the varagr parameter must be the last in the method's signature.


In Java it's called varargs, and the syntax looks like a regular parameter, but with an ellipsis ("...") after the type:

public void foo(Object... bar) {
    for (Object baz : bar) {
        System.out.println(baz.toString());
    }
}

The vararg parameter must always be the last parameter in the method signature, and is accessed as if you received an array of that type (e.g. Object[] in this case).