Comparable:
Comparable interface present in java.lang package.
It is meant for default natural sorting order.
It contains only one method i.e. compareTo( )
String and all wrapper classes implements comparable interface.
Comparator:
Comparator interface present in java.util package.
It is meant for customized sorting order.
The only implemented class are collator and RuleBasedCollator.
It contains two methods:
1)compare( )
2)equals( )
#collectioninjava
#collectioninterviewquestion
#java
#javainterviewquestion If you want to help us for enlarging our channel, then please donate us by your own wish:
Paytm: 7509058785
Upi: 7509058785@ybl