code: public char[] toCharArray(int start, int end) {
          int length = end - start;
          if (length == 0) {
              return EmptyArrays.EMPTY_CHARS;
          }
  
          if (isOutOfBounds(start, length, length())) {
              throw new IndexOutOfBoundsException("expected: " + "0 <= start(" + start + ") <= srcIdx + length("
                              + length + ") <= srcLen(" + length() + ')');
          }
  
          final char[] buffer = new char[length];
          for (int i = 0, j = start + arrayOffset(); i < length; i++, j++) {
              buffer[i] = b2c(value[j]);
          }
          return buffer;
      }
docs: Copies the characters in this string to a character array.
  
  @return a character array containing the characters of this string.