链式实现栈(后进先出)
import java.util.LinkedList;
public class stack{
private LinkedList<object> list = new LinkedList<object>();
public object push(int n){
list.addFirst(n);
}
public object pop(){
return list.removeFirst();
}
public object peek(){
return list.getFirst();
}
public boolean empty(){
return list.isEmpty();
}
}
#简单实现栈#