public class Stack {
private LinkedList list = new LinkedList(); //创建LinkedList对象
public void in(Object obj) {
list.addLast(obj); //封装addLast()方法
}
public Object out() {
return list.removeLast(); //封装removeLast()方法
}
public boolean isEmpty() {
return list.isEmpty(); //封装isEmpty()方法
}
}
|
|