What is the difference between Comparable and Comparator?
Page 1 of 1
What is the difference between Comparable and Comparator?
Comparable
Comparable provides only one sort of sequence.
It provides one method named compareTo().
It is found in java.lang package.
If we implement Comparable interface, actual class is modified.
Comparator
Comparator provides multiple sort of sequences.
It provides one method named compare().
it is found in java.util package.
Actual class is not modified.
Comparable provides only one sort of sequence.
It provides one method named compareTo().
It is found in java.lang package.
If we implement Comparable interface, actual class is modified.
Comparator
Comparator provides multiple sort of sequences.
It provides one method named compare().
it is found in java.util package.
Actual class is not modified.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum