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 the console in java?

666


Is singleton set an interval?

522


What is :: operator in java 8?

552


What does escaping a character mean?

528


why are wait(), notify() and notifyall() methods defined in the object class? : Java thread

543






What is Enum in Java?

675


Tell me the Importent classes in net package?

1578


Is it possible to write a regular expression to check if string is a number?

534


What is the difference between the paint() and repaint() methods?

576


What is a hashmap used for?

638


What is keyword in oop?

510


What is a jit compiler?

627


What is subsequence of a string?

594


Define inheritance?

542


What are instance variables?

602