What will be the output of following program?
import java.util.*;
public class StudentsPriority {
public static void main(String[] args) {
PriorityQueue<Student1> pq = new PriorityQueue<Student1>();
pq.add(new Student1(15, "Pramod"));
pq.add(new Student1(5, "Soumya"));
pq.add(new Student1(2, "Santosh"));
pq.add(new Student1(13, "Nyamath"));
pq.peek().print();
pq.element().print();
pq.poll().print();
pq.element().print();
}
}
class Student1 implements Comparable<Student1> {
int id;
String name;
public Student1(int id, String name) {
this.id = id;
this.name = name;
}
public int compareTo(Student1 other) {
return id - other.id;
}
public void print() {
System.out.print(id + "-" + name + ",");
}
}