@ Override public int compareTo ( CharSequence string ) { if ( this == string ) { return 0 ; } int result ; int length1 = length ( ) ; int length2 = string . length ( ) ; int minLength = Math . min ( length1 , length2 ) ; for ( int i = 0 , j = arrayOffset ( ) ; i < minLength ; i ++ , j ++ ) { result = b2c ( value [ j ] ) - string . charAt ( i ) ; if ( result != 0 ) { return result ; } } return length1 - length2 ; }
Compares the specified string to this string using the ASCII 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 an ASCII value which is less than the ASCII value of the character at the same position in the specified string or if this string is a prefix of the specified string . Returns a positive integer if the first non - equal character in this string has a ASCII value which is greater than the ASCII value of the character at the same position in the specified string or if the specified string is a prefix of this string .