Here is the source code:
Deletes an item at the specified position in this list. Shifts any subsequent elements to the left (subtracts one of their indices). Parameters: index the index of the item to be deleted. Returns: element that has been removed from the Throws list: java.lang.IndexOutOfBoundsException
public E remove(int index) { rangeCheck(index); modCount++; E oldValue = elementData(index); int numMoved = size - index - 1; if (numMoved > 0) System.arraycopy(elementData, index+1, elementData, index, numMoved); elementData[--size] = null; // Let gc do its work return oldValue; }
My question is:
Since rangeCheck (index) already guarantees that the index is <size, is it necessary to check that if (numMoved > 0) ?
source share