wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes how to define comparator myself? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to define comparator myself?" Watch "how to define comparator myself?" New topic

how to define comparator myself?

lijun wang

Joined: Jan 20, 2006
Posts: 28
can I define the comarator?
for example, how can I define first>second or first<second?
String.CASE_INSENSITIVE_ORDER.compare(first, second)

Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Yes, you can create a class definition which implements the Comparator interface.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Here is the source code for CASE_INSENSITIVE_ORDER, as an example:

Does anyone know why it uses both toUpperCase and toLowerCase?

There is no emoticon for what I am feeling!
Yuriy Zilbergleyt
Ranch Hand

Joined: Dec 13, 2004
Posts: 429
Originally posted by Jeff Albertson:

Does anyone know why it uses both toUpperCase and toLowerCase?

Yeah, that does look mighty strange. I can't think of a case when (Character.toUpperCase(c1) != Character.toUpperCase(c2) && Character.toLowerCase(c1) == Character.toLowerCase(c2)) evaluates to true. Are they just being overparanoid?

I agree. Here's the link: http://aspose.com/file-tools
subject: how to define comparator myself?
Similar Threads
A Question about The Life Cycle of a Stateless Session Bean
Using a multidimensional array
Kathy's latest horse video :)
How map the first servlet to second servlet