In order to not have to pass in the compareTo method for the priority queue, you need to have to write compareTo methods to compensate. Example: public int compareTo(Entry b){ if (key<b.key) return -1; if(key>b.key) return 1; return 0; }