difference between Java compare and compareTo methods
Does anybody know the differences between Java compare method (implements Comparator interface) and Java compareTo method (implements interface Comparable)?
The only obvious difference, which i have understood, is that that "compare" uses 2 arguments, while "compareTo" uses 1 argument. |
precisely.
A comparable is an object which knows can can compare itself with other objects. A comparator compares two other objects which need not know how to compare themselves with other objects. |
or should i say an instance of
|
All times are GMT -5. The time now is 06:37 PM. |