Thanks, but:
equals doesn't compare: it only returns true or false, not -1, 0 and 1.
I use it in a custom Comporator to sort a List with Collections.sort(),
The CompareToBuilder is a bit overkill: I just need to compare 2
strings, null safe.
Not that it's hard or a lot to write :) just wanted
-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Geoffrey De Smet
Sent: Monday, February 20, 2006 6:05 AM
Is there a null-safe compare method?
I need to compare 2 strings:
- both null = equal
- one null = that one is smaller
- neither null = a.compareTo(b)
Else
Specifically for strings use this:
http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringUtils.h
tml#equals(java.lang.String,%20java.lang.String)
For more generic handling of comparison checking: