Java Code:
import java.util.Stack;

public class StackExample {
  public static void main(String args[]) {
    Stack s = new Stack();
    s.push("Java");
    s.push("Forums");
    s.push("and");

    System.out.println("Next: " + s.peek());
    s.push("Tips");
    System.out.println(s.pop());
    s.push(".");
    int count = s.search("Java");
    while (count != -1 && count > 1) {
      s.pop();
      count--;
    }
    System.out.println(s.pop());
    System.out.println(s.empty());
  }
}