A Comparator is a software mechanism that defines how objects are ordered — it tells us whether A < B, A = B, or A > B.
# java.util package
public int compare(Object o1, Object o2)
Returns:
o1 < o2o1 == o2o1 > o2The actual numeric value doesn’t matter (only the sign does).
For all a, b, c in set S:
A Priority Queue is like a queue, but each item has a priority. Only the “highest-priority” (lowest key) element can be removed first.