/*
使用LinkedList模拟一个堆栈或者队列数据结构。
堆栈:先进后出
队列:先进先出 First in First out FIFO
*/
import java.util.*;
class Queue
{
private LinkedList link;
Queue()
{
link = new LinkedList();
}
public void myAdd(Object obj)
{
link.addFirst(obj);
}
public Object myGet()
{
return link.removeFirst();//return link.removeLast();
}
public boolean isNull()
{
return link.isEmpty();
}
}
class LinkedListTest
{
public static void main(String[] args)
{
Queue q = new Queue();