code: private void checkIndex(int length) {
          if (maxLength == Integer.MAX_VALUE && knownLength < length)
              knownLength = length;
          else if (length < 0 || length >= maxLength)
              throw new IllegalArgumentException("Length must be non negative " +
                      "and less than the maximum length");
      }
docs: If {@code length} is longer than the currently known reset the value of
  {@code knownLength}.