/Users/lyon/j4p/src/collections/linkedlist/Queue.java
|
1 /*
2 * Queue.java
3 *
4 * Created on December 4, 2002
5 */
6
7 package collections.linkedlist;
8
9 import java.util.LinkedList;
10
11 /**
12 * Shows how to use a linkedList as a Queue
13 * @author Thomas Rowland
14 */
15 public class Queue {
16
17 LinkedList queue = new LinkedList();
18
19 public static void main(String[] args) {
20 Queue queue = new Queue();
21 queue.add("good");
22 queue.add("bad");
23 queue.add("ugly");
24
25 System.out.println(queue.remove());
26 System.out.println(queue.remove());
27 System.out.println(queue.remove());
28 }
29
30 public void add(Object o) {
31 queue.addLast(o);
32 }
33
34 public Object remove() {
35 return queue.removeFirst();
36 }
37
38 }
39