public int indexOf ( CharSequence subString , int start ) { final int subCount = subString . length ( ) ; if ( start < 0 ) { start = 0 ; } if ( subCount <= 0 ) { return start < length ? start : length ; } if ( subCount > length - start ) { return INDEX_NOT_FOUND ; } final char firstChar = subString . charAt ( 0 ) ; if ( firstChar > MAX_CHAR_VALUE ) { return INDEX_NOT_FOUND ; } final byte firstCharAsByte = c2b0 ( firstChar ) ; final int len = offset + length - subCount ; for ( int i = start + offset ; i <= len ; ++ i ) { if ( value [ i ] == firstCharAsByte ) { int o1 = i , o2 = 0 ; while ( ++ o2 < subCount && b2c ( value [ ++ o1 ] ) == subString . charAt ( o2 ) ) { // Intentionally empty } if ( o2 == subCount ) { return i - offset ; } } } return INDEX_NOT_FOUND ; }
Searches in this string for the index of the specified string . The search for the string starts at the specified offset and moves towards the end of this string .