ContactUs :

Please send your Questions & Answers or Feedback to "mohan@javabook.org"

What are the differences between the Comparable and Comparator interfaces ?


Comparable :
It uses the compareTo() method.
int objectOne.compareTo(objectTwo).
It is necessary to modify the class whose instance is going to be sorted.
Only one sort sequence can be created.
It is frequently used by the API classes.

Comparator :
It uses the compare() method.
int compare(ObjOne, ObjTwo)
A separate class can be created in order to sort the instances.
Many sort sequences can be created.
It used by third-party classes to sort instances.

Related Posts Plugin for WordPress, Blogger...
Flag Counter