// Print the contents of the stack import java.util.*; class mystack { public void print_stack(Stack p) { Stack q = new Stack(); Object x; System.out.print("Stack: "); while (! p.empty()) { x = p.pop(); System.out.print(x + " "); q.push(x); } System.out.print("\n"); while (! q.empty()) p.push(q.pop()); } }