How come the elements of priority queue are ordered according to natural order by default as it doesn\'t implement comparable interface.
From the docs, it says elem
Actually PriorityQueue allows only those elements which implements Comparable or you need to provide Custom Comparator.
Integer and String values are allowed in Comparator because they implement Comparable interface. e.g. public final class String implements java.io.Serializable, Comparable, CharSequence
public final class Integer extends Number implements Comparable
If you create your own class e.g Employee then it should implement Comparable or you should provide your custom Comparator.
I hope this will resolve your queries!!!!