Java tutorial
import java.util.Stack; public class MainClass { public static void main(String args[]) { Stack s = new Stack(); s.push("A"); s.push("B"); s.push("C"); System.out.println("Next: " + s.peek()); s.push("D"); System.out.println(s.pop()); s.push("E"); s.push("F"); int count = s.search("E"); while (count != -1 && count > 1) { s.pop(); count--; } System.out.println(s); } }