import java.util.*; // // First In First Out // Stack // // public class LIFO{ Vector list; int l=0; LIFO(){ list=new Vector(); } // Put on stack -- add below on the stack .. the first on the stack goes first off the stack public void push(String S){ list.addElement((String)S); l++; // length=list.size(); } // Get the first available member and remove it public String pop(){ String retval=null; if(!list.isEmpty()){ retval=(String)list.lastElement(); list.removeElementAt(l); } l--; // length=list.size(); return retval; } //Investigate the first available member without removing it! public String next(){ String retval=null; if(!list.isEmpty()){ retval=(String)list.lastElement(); } return retval; } public boolean isEmpty(){ return list.isEmpty(); } public void clear(){ list.clear(); l=0; // while(!list.isEmpty()){ // list.removeElementAt(0); // } } }