Compares the character values of this string and compares it to the character values of the other string. Smaller strings always precede longer strings. This is equivalent to the standard POSIX strcmp() with the "C" locale. Internally this does not handle the special variants of this clas
(String __os)
| 347 | * @since 2016/04/02 |
| 348 | */ |
| 349 | public int compareTo(String __os) |
| 350 | throws NullPointerException |
| 351 | { |
| 352 | // Check |
| 353 | if (__os == null) |
| 354 | throw new NullPointerException("NARG"); |
| 355 | |
| 356 | // Get both string lengths |
| 357 | int an = this.length(); |
| 358 | int bn = __os.length(); |
| 359 | |
| 360 | // Max comparison length |
| 361 | int max = Math.min(an, bn); |
| 362 | |
| 363 | // Compare both strings |
| 364 | for (int i = 0; i < max; i++) |
| 365 | { |
| 366 | // Get character difference |
| 367 | int diff = ((int)this.charAt(i)) - ((int)__os.charAt(i)); |
| 368 | |
| 369 | // If there is a difference, then return it |
| 370 | if (diff != 0) |
| 371 | return diff; |
| 372 | } |
| 373 | |
| 374 | // Remaining comparison is the length parameter, shorter strings are |
| 375 | // first |
| 376 | return an - bn; |
| 377 | } |
| 378 | |
| 379 | /** |
| 380 | * Compares two strings lexicographically without regards to case. This |