-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPriorityQueueExample2.java
More file actions
33 lines (24 loc) · 897 Bytes
/
Copy pathPriorityQueueExample2.java
File metadata and controls
33 lines (24 loc) · 897 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
package queueInterface;
import java.util.PriorityQueue;
public class PriorityQueueExample2 {
public static void main(String[] args) {
PriorityQueue<Student> students = new PriorityQueue<>();
Student st1 = new Student("John", 2);
Student st2 = new Student("Helen", 3);
Student st3 = new Student("Gary", 1);
Student st4 = new Student("Peter", 4);
Student st5 = new Student("Edward", 5);
students.add(st1);
students.add(st2);
students.add(st3);
students.add(st4);
students.add(st5);
System.out.println(students);
System.out.println(students.poll());
System.out.println(students.poll());
System.out.println(students.poll());
System.out.println(students.poll());
System.out.println(students.poll());
System.out.println(students.poll());
}
}