Compatable

what is diffence between comparator and compatable in JAVA

Definition Both interfaces are very similer because they are for sorting lists and arrays. However, one is for one condition and other one is for mutiple conditions. Difference Comparable Comparator java.lang package. java.util package. Comparable affects the original class Comparator doesn’t affect the original class compareTo() method with 1 parameter compare() method with 2 parameters Collections.sort(List) Collections.sort(List, Comparator) Arrays.