Question: what is the difference between comparator and comparable in java?
Answer: Comparator interface belongs to java. util package while comparable belongs to java. lang package. Comparator interface sort collection using two objects provided to it, whereas comparable interface compares" this" refers to the one objects provided to it.