void (final int index, final boolean excludes) { final int max = excludes ? size - 1 : size; if (index < 0 || index > max) { throw new IndexOutOfBoundsException("Index: " + index + " Size: " + size); } }