Varargs
Accept a variable number of arguments as an array.
Easy
static int sum(int... xs) { int s = 0; for (int x : xs) s += x; return s; } → sum(1, 2, 3).
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.