this question has answer here:
- what ellipsis (…) in method signature? 6 answers
- java, 3 dots in parameters 9 answers
i came across method definition:
void dotype(int... keycodes) { dotype(keycodes, 0, keycodes.length); } void dotype(int[] keycodes, int offset, int length) { if (length == 0) { return; } robot.keypress(keycodes[offset]); dotype(keycodes, offset + 1, length - 1); robot.keyrelease(keycodes[offset]); }
the "int..." seems indicate indeterminate number of integer parameters variable used array inside function. can please explain?
as stated correctly java notation make method accept variable amount of (in case) int parameter.
to handle variable amount of variables can access array.
this functionality introduced in java 5.
see here:
https://docs.oracle.com/javase/1.5.0/docs/guide/language/varargs.html
Comments
Post a Comment