Kotlinlearncs.online LogoJava
Return to List

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.

int stackSum(Stack<Integer> stack) {
return 0; // You may need to remove this starter code
}

Related Lessons

Stuck? You may find these lessons helpful: