Closed dstarh closed 8 years ago
@dstarh Nope there is no problem at all. It's dynamically growing(just like ArrayList) so the expression index > size is valid.
If you look ArrayList source code, you will see this following method:
/**
* A version of rangeCheck used by add and addAll.
*/
private void rangeCheckForAdd(int index) {
if (index > size || index < 0)
throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
}
Am I crazy or is there an off by one error here?
A list of size 1 does not have anything at index 1