code: public String substring(int start, int end) {
          int length = end - start;
          if (start > pos || length > pos) {
              throw new IndexOutOfBoundsException();
          }
          return new String(chars, start, length);
      }
docs: Create a new {@link String} from the given start to end.