Both Comparable and Comparator are interfaces; then how is that we can overide compare() method of Comparator many times and we use compareTo() method belonging to Comparable only once?
am not sure my understanding abt this concept is clear or not!!!
For comparable you have to change the class whose instance you want to sort For comparator we create a new class which implement comparator interface In this new class we override compare method of comparator. we can create many class who can implements comparator and override compare method the manner we want it. and while sorting we pass the argument of class which implement comparator
Mo-om! You're embarassing me! Can you just read a tiny ad like a normal person?
Gift giving made easy with the permaculture playing cards