File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes diff b/w compare() and compareTo() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "diff b/w compare() and compareTo()" Watch "diff b/w compare() and compareTo()" New topic

diff b/w compare() and compareTo()

amit bhadre
Ranch Hand

Joined: Jan 23, 2006
Posts: 124
what is difference between compare() and compareTo()....

Thanks advance who ever answers this question.

amit bhadre
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

which class ?

[My Blog]
All roads lead to JavaRanch
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Q: What's the diference between java.util.Comparator and java.lang.Comparable?

A: A comparator compares two given objects, so there are three references involved:

A comparable compares (itself) to another object, so there are two refernces involved:

There is no emoticon for what I am feeling!
I agree. Here's the link:
subject: diff b/w compare() and compareTo()
It's not a secret anymore!