Solve: Stack Sum
Created By: Justin Maier
/ Version: 2024.12.0
Complete the method sumStack
that takes a Stack<Integer>
as an argument and returns the sum of values in the
stack.
If the argument is null
, throw an IllegalArgumentException
.
For this problem we're expecting only a method.
Don't define a class, include modifiers like static or public, add import statements, or add code outside the method declaration.You may use the following packages for this problem without importing them: java.util.Stack
int stackSum(Stack<Integer> stack) {
return 0;
}