vote up 2 vote down
star

I've seen this before in a method parameter, and it appears to allow an arbitrary number of parameters to be stuffed in an array created at run-time. What's the official name of this language feature? Thanks!

    public static void trace(View view, RecyclerTraceType type, int... parameters) {

    RecyclerTrace trace = new RecyclerTrace();
    trace.position = parameters[0];
    trace.indexOnScreen = parameters[1];
}
flag
add comment

2 Answers:

vote up 8 vote down
check

You are seeing the Java 1.5 varargs feature. Under the hoods its just an array with syntactic sugaring.

link|flag
add comment
vote up 1 vote down

Variadic Functions

link|flag
add comment

Your Answer:

Get an OpenID
or

Not the answer you're looking for? Browse other questions tagged or ask your own question.