Comparable Interface | Comparator Interface |
---|---|
It uses the compareTo() method. | It uses the compare() method. |
It is necessary to modify the class whose instance is going to be sorted. | A separate class can be created in order to sort the instances. |
Only one sort sequence can be created. | Many sort sequences can be created. |
It is frequently used by the API classes. | It it used by third-party classes to sort instances. |
Welcome to the Java Blog, written by me with the sole purpose of talking about Java & Web technologies. I'm aiming this blog at other Java developers with the deeper aspects of writing code and resolving technical issues. Hopefully I can blog about some really interesting topics as I come across them. Mr. Patricia Seybold said, "If you learn to program in Java, you’ll never be without a job!"
Friday, May 29, 2009
Differences between the Comparable and Comparator interfaces
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment