Diff between Comparator and Comparable?
Answer Posted / qim2010
The “Comparable” interface allows itself to compare with
another similar object (i.e. A class that implements Comparable
becomes an object to be compared with). The following method
are specified in the interface.
public int compareTo(Object o)
public int compareToIgnoreCase(String str)
The "Comparator" interface is used to compare two different
objects. The following method is specified in the Comparator
interface.
public int compare(Object o1, Object o2)
| Is This Answer Correct ? | 8 Yes | 0 No |
Post New Answer View All Answers
Can we have static methods in an interface?
What is r in java?
What is Java Shutdown Hook?
Can you achieve runtime polymorphism by data members?
What is string data?
What is a method vs function?
What are the loops in java?
Can It is possible to synchronize the constructor of a Java Class?
Which is better ascii or unicode?
Can a static method be overridden in java?
Difference between default and protected access specifiers?
How do you execute a thread in java?
What is string value?
What is meant by data hiding/encapsulation?
What is %d in printf?