Request for Enhancement: Objects.checkPositionIndex(int, int)

Glavo zjx001202 at gmail.com
Mon Jan 13 19:36:40 UTC 2025


Currently the java.util.Objects provide the method `checkIndex(int, int)`
for checking indexes.
It is convenient, but cannot be used to implement methods such as
List::add(int, E) because these methods accept an index pointing to the end
of the collection.
So is it possible to add a new method to Objects to check this kind of
index?
This is useful for implementing collections.
(The checkPositionIndex in the title is its name in guava. I don't like the
name, but I don't have a better idea.)

Glavo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250114/4b0637b4/attachment-0001.htm>


More information about the core-libs-dev mailing list