//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Problem 6.14 on page 121
//  Testing another reversed(Stack) method

import java.util.Stack;

public class Pr0614
{ public static void main(String[] args)
  { Stack kids = new Stack();
    kids.push("Sara");
    kids.push("John");
    kids.push("Andy");
    kids.push("Mike");
    System.out.println(kids);
    System.out.println(reversed(kids));
  }
  
  private static Stack reversed(Stack stack)
  { Stack copiedStack = (Stack)stack.clone();
    Stack newStack = new Stack();
    while(!copiedStack.empty())
      newStack.push(copiedStack.pop());
    return newStack;
  }
}
  