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


Please Help Members By Posting Answers For Below Questions

What is java objectoutputstream?

626


What is time complexity java?

627


What is the use of conditional statement?

646


What is type conversion in java?

664


What class allows you to read objects directly from a stream?

980






Explain about map interface in java?

672


What are the differences between processes and threads?

622


What is main function purpose?

614


What is the difference in between cpp and java? Can u explain in detail?

697


What is constructor chaining and how is it achieved in java?

662


When wait(), notify(), notifyall() methods are called does it releases the lock or holds the acquired lock?

642


How define set in java?

623


If a method is declared as protected, where may the method be accessed?

620


Do extraneous variables affect validity?

598


What is a finally block?

650