code: protected static final void checkOffset(int offset, CharacterIterator text) {
          if (offset < text.getBeginIndex() || offset > text.getEndIndex()) {
              throw new IllegalArgumentException("offset out of bounds");
          }
      }
docs: Throw IllegalArgumentException unless begin &lt;= offset &lt; end.