Possible Duplicates:
What does “…” mean in Java?
Java array argument “declaration” syntax
Can anyone confirm if I’m right in seeing the Object... parameter in the method call below:
public static void setValues(PreparedStatement preparedStatement, Object... values)
throws SQLException
{
for (int i = 0; i < values.length; i++) {
preparedStatement.setObject(i + 1, values[i]);
}
}
As an array of type Object? I don’t recall seeing ... before in Java.
It’s equivalent to
Object[], but allows the caller to just specify the values one at a time as arguments, and the compiler will create an array. So this call:is equivalent to
See the documentation for the varargs feature (introduced in Java 5) for more information.