Answer by lkamal for Java comparators and comparable
Simple AnswerGo for Comparator.Summary of two concepts(extracted from http://www.digizol.com/2008/07/java-sorting-comparator-vs-comparable.html)ComparableA comparable object is capable of comparing...
View ArticleAnswer by Chakradhar K for Java comparators and comparable
If possible you can extend the class and write a new class, which implements Comparable so that you can implement compareTo(). In other case you can use, Comparator as given ,class MyComparator...
View ArticleAnswer by amicngh for Java comparators and comparable
If you don't have access to source file then use Comparator to sort them. class MyComparator implements Comparator<MyClass>{@Overridepublic int compare(MyClass o1, MyClass o2) { return...
View ArticleAnswer by Stephen Connolly for Java comparators and comparable
Comparable is an interface implemented by classes that know how to compare themselfs with another instance of that class.Comparator is an interface for comparing two instances of a different class.If...
View ArticleJava comparators and comparable
I have only class files and no source code in java, Now I have to sort them, what shall I use Comparator or Comparable? Appreciate your help.
View Article