Sum with Varargs
mediumQuestion 408Write 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, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
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.