1.

What Is The Difference Between Comparable And Comparator?

Answer»

Comparable:

  • Comparable PROVIDES only ONE sort of SEQUENCE.
  • It provides one method named compareTo().
  • It is found in java.lang package.
  • If we implement Comparable interface, actual CLASS is modified.

Comparator:

  • Comparator provides multiple sort of sequences.
  • It provides one method named compare().
  • it is found in java.util package.
  • Actual class is not modified.

Comparable:

Comparator:



Discussion

No Comment Found