G
gaurav
what's the difference between comparable and comparator interface.
gaurav said:what's the difference between comparable and comparator interface.
what's the difference between comparable and comparator interface.
In comp.lang.java.help Michiel Konstapel said:Something that's Comparable knows how to compare itself to others
(presumably of the same class). How it does so is built into the class.
For example, Strings compare themselves alphabetically (well, by character
value, anyway). A Comparator can compare two other objects by whatever
criterion the Comparator chooses. For example, it might compare Strings by
their length.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.