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
Why is a string immutable?
Explain about version control?
Is void a data type in java?
How do you check if two given string are anagrams?
What is void class in java?
What is nested interface?
How is java hashmap implemented?
Why is a constant variable important?
What is a finally block?
What is the major difference between linkedlist and arraylist?
How dead lock situation occurs in java and how you can identify it?
Which method cannot be overridden in java?
Can we call a non-static method from inside a static method?
What is a prefix function.write down a code to compute prefix function.
What is the use of jtable?