docs: public static void checkIndex(int index, int size) {
      if (size < 0) {
        throw new IllegalArgumentException("Negative size: " + size);
      }
      if (index < 0 || index >= size) {
        throw new IndexOutOfBoundsException("Index out of bounds: size=" + size + ", index=" + index);
      }
    }