Compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings. The character sequence represented by this String object is compared lexicographically to the character sequence represented by the argument string. The result is a negative integer
(java.lang.String anotherString)
| 192 | * this.charAt(k)-anotherString.charAt(k) If there is no index position at which they differ, then the shorter string lexicographically precedes the longer string. In this case, compareTo returns the difference of the lengths of the strings -- that is, the value: this.length()-anotherString.length() |
| 193 | */ |
| 194 | public int compareTo(java.lang.String anotherString){ |
| 195 | if(anotherString == this) { |
| 196 | return 0; |
| 197 | } |
| 198 | int minL = Math.min(anotherString.length(), length()); |
| 199 | for(int iter = 0 ; iter < minL ; iter++) { |
| 200 | char a = value[offset + iter]; |
| 201 | char b = anotherString.value[anotherString.offset + iter]; |
| 202 | if(a != b) { |
| 203 | return a - b; |
| 204 | } |
| 205 | } |
| 206 | return length() - anotherString.length(); |
| 207 | } |
| 208 | |
| 209 | public int compareToIgnoreCase(java.lang.String anotherString) { |
| 210 | if (anotherString == this) { |
no test coverage detected