第1个回答 2010-07-17
class Stack<T> {
private Vector<T> v;
public Stack(){
v = new Vector<T>();
}
public T pop(){
if (v.size()==0) return null;
return v.get(v.size()-1);
}
public void push(T t){
v.add(t);
}
public boolean isEmpty(){
return v.size()==0;
}
}
class Queue<T>{
private Vector<T> v;
public Queue(){
v = new Vector<T>();
}
//入队列
public void enqueue(T t){
v.add(t);
}
//出队列
public T dequeue(){
if (v.size()==0) return null;
return v.get(0);
}
public boolean isEmpty(){
return v.size() == 0;
}
}本回答被提问者采纳