Compares the specified string to this string using the Unicode values of the characters. Returns 0 if the strings contain the same characters in the same order. Returns a negative integer if the first non-equal character in this string has a Unicode value which is less than the Unicode value of the
(String string)
| 600 | * if {@code string} is {@code null}. |
| 601 | */ |
| 602 | public int compareTo(String string) { |
| 603 | // Code adapted from K&R, pg 101 |
| 604 | int o1 = offset, o2 = string.offset, result; |
| 605 | int end = offset + (count < string.count ? count : string.count); |
| 606 | char[] target = string.value; |
| 607 | while (o1 < end) { |
| 608 | if ((result = value[o1++] - target[o2++]) != 0) { |
| 609 | return result; |
| 610 | } |
| 611 | } |
| 612 | return count - string.count; |
| 613 | } |
| 614 | |
| 615 | /** |
| 616 | * Compares the specified string to this string using the Unicode values of |