int len = endIndex - beginIndex; if (beginIndex < 0 || endIndex > count || len < 0) throw new StringIndexOutOfBoundsException(); if (len == 0) return "";  shared = (len << 2) >= value.length;  return new String(value, beginIndex, len, shared);
return substring(beginIndex, count);
  public synchronized String substring(int beginIndex, int endIndex)  {    int len = endIndex - beginIndex;    if (beginIndex < 0 || endIndex > count || len < 0)      throw new StringIndexOutOfBoundsException();    if (len == 0)      return "";    // Share the char[] unless 3/4 empty.    shared = (len << 2) >= value.length;    // Package constructor avoids an array copy.    return new String(value, beginIndex, len, shared);  }