代码如下
package com.shengsiyuan;
import java.util.LinkedList;
public class MyQueue
{
private LinkedList list = new LinkedList();
public void put(Object o)
{
list.addLast(o);
}
public Object get()
{
return list.removeFirst();
}
public boolean isEmpty()
{
return list.isEmpty();
}
public static void main(String[] args)
{
MyQueue myQueue = new MyQueue();
myQueue.put("1");
myQueue.put("2");
myQueue.put("3");
System.out.println(myQueue.get());
System.out.println(myQueue.get());
System.out.println(myQueue.get());
System.out.println(myQueue.isEmpty());
}
运行结果