CJCoding With Joseph
15free / daySign inCreate account

Sum with Varargs

Write a static method named sum that accepts a variable number of int arguments (varargs) and returns their total. In main, print the results of two calls, each on its own line, exactly (see Expected Output).

The first call is sum(1, 2, 3) (which is 6) and the second is sum(10, 20, 30, 40) (which is 100).

Expected Output:

6
100

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Miscellaneous
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.