The last parameter in the list is defined with a "type ... variable_name" syntax (note the ellipsis).
Example:
private static int sum(int ... numbers) {
int accum = 0;
for (int i=0; i<numbers.length; i++) {
accum += numbers[i];
}
return accum;
}
No comments:
Post a Comment