-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathQueueUsingArrayClient.java
45 lines (33 loc) Β· 1.19 KB
/
QueueUsingArrayClient.java
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
40
41
42
43
44
45
package Lecture16;
public class QueueUsingArrayClient {
public static void main(String[] args) throws Exception {
int capacity = 6;
QueuesUsingArray queue = new QueuesUsingArray(capacity);
System.out.println("Queue in the beginning");
System.out.println("Queue is empty: " + queue.isEmpty());
queue.display();
System.out.println("========================");
for (int i = 10; i <= 60; i += 10) {
queue.enqueue(i);
queue.display();
System.out.println("-----------------");
}
System.out.println("\nAfter enqueue operations");
System.out.println("Queue is empty: " + queue.isEmpty());
queue.display();
System.out.println("size of queue is: " + queue.queueSize());
System.out.println("========================");
System.out.println("\ndequeuing.............\n");
for (int i = 0; i < capacity; i++) {
queue.display();
queue.dequeue();
System.out.println("-----------------");
}
System.out.println("\nAfter dequeue operations");
queue.display();
System.out.println("size of queue is: " + queue.queueSize());
System.out.println("========================");
// queue.dequeue(); // Exception in thread "main" java.lang.Exception:
// queue is empty
}
}