question: public int indexOf ( final String str , int startIndex ) { startIndex = ( startIndex < 0 ? 0 : startIndex ) ; if ( str == null || startIndex >= size ) { return - 1 ; } final int strLen = str . length ( ) ; if ( strLen == 1 ) { return indexOf ( str . charAt ( 0 ) , startIndex ) ; } if ( strLen == 0 ) { return startIndex ; } if ( strLen > size ) { return - 1 ; } final char [ ] thisBuf = buffer ; final int len = size - strLen + 1 ; outer : for ( int i = startIndex ; i < len ; i ++ ) { for ( int j = 0 ; j < strLen ; j ++ ) { if ( str . charAt ( j ) != thisBuf [ i + j ] ) { continue outer ; } } return i ; } return - 1 ; }
target:  Searches the string builder to find the first reference to the specified string starting searching from the given index. <p> Note that a null input string will return -1, whereas the JDK throws an exception.