This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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()
jQuery in Action, 3rd edition