WHAT IS THE DIFFERENCE BETWEEN COMPARABLE AND COMPARATOR?

Mayank Tripathi

Total Post:807

Points:4035
Posted by  Mayank Tripathi
 849  View(s)
Ratings:
Rate this:
  1. Mayank Tripathi

    Post:807

    Points:4035
    What is the difference between Comparable and Comparator?

    Comparable
    1) Comparable provides only one sort of sequence.
    2) It provides one method named compareTo().
    3) It is found in java.lang package.
    4) If we implement Comparable interface, actual class is modified.

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

      Modified On May-13-2015 12:04:56 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!