This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes What is the difference between Comparator and Comparable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is the difference between Comparator and Comparable" Watch "What is the difference between Comparator and Comparable" New topic
Author

What is the difference between Comparator and Comparable

Hemant Agarwal
Ranch Hand

Joined: Nov 21, 2005
Posts: 138
What is the difference between Comparator and Comparable?
Renato Losio
Ranch Hand

Joined: Nov 23, 2005
Posts: 99
A detailed explanation (with examples) on
ONJava

Extract from the article:

Implementing the Comparable interface enables you to define one way to compare instances of your class. However, objects are sometimes comparable in many ways. For example, two Person objects may need to be compared by age or by last/first name. In cases like this, create a Comparator that defines how to compare two objects. To make objects comparable in two ways, then you need two comparators.


Renato Losio - www.arsenio.it - renatoweb@arsenio.it
Sri Ram
Ranch Hand

Joined: Oct 03, 2005
Posts: 118
U can get the details from here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the difference between Comparator and Comparable
 
Similar Threads
Comparable and Comparator
Difference in between comparable and comparator interface
difference between Comparator and Comparable interface
Comparator & Comparable
Comparable and Comparator