Java Associate — Hard
Key points
- Comparable defines natural ordering within the class; Comparator allows for custom comparison logic
- Comparable uses `compareTo()`; Comparator uses `compare()`
- Comparable is implemented by the class itself; Comparator is implemented externally
- Comparable is used for natural ordering; Comparator is used for custom ordering
Ready to go further?
Related questions
