forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleQueue.java
More file actions
39 lines (31 loc) · 919 Bytes
/
SimpleQueue.java
File metadata and controls
39 lines (31 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.company;
import java.util.LinkedList;
import java.util.Queue;
public class SimpleQueue
{
public static void main(String[]args)
{
SimpleQueue simpleQueue = new SimpleQueue();
simpleQueue.run();
}
static void run()
{
Queue<String> myQueue = new LinkedList<>();
myQueue.add("One");
myQueue.add("Two");
myQueue.add("Three");
myQueue.add("Four");
myQueue.add("Five");
System.out.println(myQueue);
System.out.println(myQueue.remove());
System.out.println(myQueue);
System.out.println(myQueue.peek());
System.out.println(myQueue);
System.out.println(myQueue.peek());
System.out.println(myQueue);
System.out.println(myQueue.peek());
System.out.println(myQueue);
System.out.println(myQueue.peek());
System.out.println(myQueue);
}
}