code: public int indexOf(CharSequence target, int fromIndex, int endIndex)
      {
          if (fromIndex < 0)
              throw new IndexOutOfBoundsException("index out of range: " + fromIndex);
          if (endIndex < 0)
              throw new IndexOutOfBoundsException("index out of range: " + endIndex);
          if (fromIndex > length())
              throw new IndexOutOfBoundsException("fromIndex > length()");
          if (fromIndex > endIndex)
              throw new IndexOutOfBoundsException("fromIndex > endIndex");
  
          if (endIndex >= builder.length())
          {
              endIndex = builder.length() - 1;
          }
  
          int targetCount = target.length();
          if (targetCount == 0)
          {
              return fromIndex;
          }
  
          char strFirstChar = target.charAt(0);
          int max = endIndex + targetCount - 1;
  
          lastCharSearch:
          for (int i = fromIndex; i <= max; i++)
          {
              if (builder.charAt(i) == strFirstChar)
              {
                  for (int j = 1; j < targetCount; j++)
                  {
                      if (builder.charAt(i + j) != target.charAt(j))
                      {
                          continue lastCharSearch;
                      }
                  }
                  return i;
              }
          }
          return -1;
      }
docs: Returns the index within this string of the first occurrence of the
  specified substring between the specified indices.
  
  <p>If no such value of {@code target} exists, then {@code -1} is returned.
  
  @param  target
  the substring to search for.
  @param  fromIndex
  the index from which to start the search.
  @param  endIndex
  the index at which to end the search.
  
  @throws java.lang.IndexOutOfBoundsException
  <ul>
  <li>If the {@code fromIndex} is outside of the range of {@code 0} to {@link #length()}</li>
  <li>If the {@code endIndex} is outside of the range of {@code 0} to {@link #length()}</li>
  <li>If the {@code fromIndex} is greater than {@code endIndex}</li>
  </ul>
  
  @return the index of the first occurrence of the specified substring between
  the specified indices or {@code -1} if there is no such occurrence.