Skip to content

Commit

Permalink
comparable and overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankush1oo8 committed Mar 9, 2024
1 parent ba2b319 commit 9cd0dc6
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Heap/PQWithObjects.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package Heap;
import java.util.*;
public class PQWithObjects {
static class student implements Comparable<student>{
int rank;
String name;

public student(String name, int rank){
this.name=name;
this.rank=rank;
}
@Override
public int compareTo(student s2){
return this.rank-s2.rank;
}
}
public static void main(String[] args) {
PriorityQueue<>pq=new PriorityQueue<>();

}
}

0 comments on commit 9cd0dc6

Please sign in to comment.