new SharedString(string.toCharArray()))
/** * Return a new subsequence beginning at @a start and continuing * to @a end. This subsequence shares the underlying char array * without copying it. */ @Override public CharSequence subSequence(int start, int end) { if (start < 0) throw new StringIndexOutOfBoundsException(start); if (end > mCount) throw new StringIndexOutOfBoundsException(end); if (start > end) throw new StringIndexOutOfBoundsException(end - start); return start == 0 && end == mCount // Simply return "this" if the start and end match exactly. ? this // Otherwise, create a new SharedString that points into // the subsequence without copying it. : new SharedString(mValue, mOffset + start, end - start); } }