本帖最后由 赵宇 于 2012-9-25 08:39 编辑
- 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("one");
- myQueue.put("two");
- myQueue.put("three");
- System.out.println(myQueue.get());
- System.out.println(myQueue.get());
- System.out.println(myQueue.get());
- System.out.println(myQueue.isEmpty());
- }
- }
复制代码 |
|