Refactoring Q2.7 to use the Stack utility class instead of the Java built-in stack.