import java.util.LinkedList;

/*

* 使用LinkedList模拟一个堆栈或队列数据结构

* 堆栈:先进后出

* 队列:先进先出

*/

public class DuiLie {

private LinkedList link;

DuiLie(){

this.link=new LinkedList();

}

private void myAdd(Object obj) {

// TODO Auto-generated method stub

link.addLast(obj);

}

private Object myGet() {

// TODO Auto-generated method stub

return link.removeFirst();

}

private boolean isNull() {

// TODO Auto-generated method stub

return link.isEmpty();

}

public static void main(String[] args) {

DuiLie dl=new DuiLie();

dl.myAdd("java01");

dl.myAdd("java02");

System.out.println(dl.myGet());



}

}