-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInQueue.java
More file actions
37 lines (22 loc) · 869 Bytes
/
InQueue.java
File metadata and controls
37 lines (22 loc) · 869 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
import java.util.PriorityQueue;
public class InQueue {
public static void main(String[] args) {
PriorityQueue <Integer> que = new PriorityQueue<>();
System.out.println("Queue is empty? : "+que.isEmpty());
que.add(12);
que.add(45);
que.add(74);
que.add(98);
que.add(47);
que.add(35);
que.add(68);
que.add(57);
System.out.println("Now the queue elements are : "+que);
que.remove();
que.remove();
System.out.println("Now the queue elements are : "+que);
System.out.println("Now the top element of queue is : "+que.peek());
System.out.println("Size of queue is : "+que.size());
System.out.println("Queue is empty? : "+que.isEmpty());
}
}