code: public String substring(final int beginIndex, final int endIndex) {
          if (beginIndex < 0) {
              throw new IndexOutOfBoundsException("Negative beginIndex: " + beginIndex);
          }
          if (endIndex > this.len) {
              throw new IndexOutOfBoundsException("endIndex: " + endIndex + " > length: " + this.len);
          }
          if (beginIndex > endIndex) {
              throw new IndexOutOfBoundsException("beginIndex: " + beginIndex + " > endIndex: " + endIndex);
          }
          return new String(this.array, beginIndex, endIndex - beginIndex);
      }
docs: Returns a substring of this buffer. The substring begins at the specified
  {@code beginIndex} and extends to the character at index
  {@code endIndex - 1}.
  
  @param      beginIndex   the beginning index, inclusive.
  @param      endIndex     the ending index, exclusive.
  @return     the specified substring.
  @throws  StringIndexOutOfBoundsException  if the
  {@code beginIndex} is negative, or
  {@code endIndex} is larger than the length of this
  buffer, or {@code beginIndex} is larger than
  {@code endIndex}.