Here's the source code:
Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices). Parameters: index the index of the element to be removed Returns: the element that was removed from the list Throws: 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:
As the rangeCheck(index) has already guarantee that index < size, is it necessary to check that if (numMoved > 0)?