if (beginIndex < 0 || endIndex > count || beginIndex > endIndex) throw new StringIndexOutOfBoundsException(); if (beginIndex == 0 && endIndex == count) return this; int len = endIndex - beginIndex;  return new String(value, beginIndex + offset, len, (len << 2) >= value.length);
return substring(begin, count);
  public String substring(int beginIndex, int endIndex)  {    if (beginIndex < 0 || endIndex > count || beginIndex > endIndex)      throw new StringIndexOutOfBoundsException();    if (beginIndex == 0 && endIndex == count)      return this;    int len = endIndex - beginIndex;    // Package constructor avoids an array copy.    return new String(value, beginIndex + offset, len,                      (len << 2) >= value.length);  }