Puede usar Stack Class en java.util
import java.util.Stack; 
public class StackExample { 
  public static void main (String args []) { 
    Stack s = new Stack (); 
    s.push ("Java"); 
    s.push ("Fuente"); 
    s.push ("y"); 
    System.out.println ("Siguiente:" + s.peek ()); 
    s.push ("Soporte"); 
    System.out.println (s.pop ()); 
    s.push ("."); 
    int count = s.search ("Java"); 
    while (cuenta! = -1 && cuenta> 1) { 
      s.pop (); 
      contar--; 
    } 
    System.out.println (s.pop ()); 
    System.out.println (s.empty ()); 
  } 
}
     Espero eso ayude, 
     cualquier otra ayuda msg me