โ Back to Methods
Question 365
Varargs Sum Method
Varargs Sum Method
Write a methodsum(int... nums)that accepts any number ofintarguments and returns their total. Callsum(1, 2, 3, 4)and print the result: 10 Loop overnumswith a for-each loop and add each value.
Expected Output:
10
Topics:
Methods
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.