/** * Replaces the element at the specified position in this list with the specified element. * * @param index index of the element to replace * @param element element to be stored at the specified position * @return the element previously at the specified position * @throws IndexOutOfBoundsException {@inheritDoc} */ @Override public Float set(int index, Float element) { rangeCheck(index); Float oldValue = elementData(index); elementData[index] = element; return oldValue; }
/** * Removes the element at the specified position in this list. Shifts any subsequent elements to * the left (subtracts one from their indices). * * @param index the index of the element to be removed * @return the element that was removed from the list * @throws IndexOutOfBoundsException {@inheritDoc} */ @Override public Float remove(int index) { rangeCheck(index); modCount++; Float oldValue = elementData(index); int numMoved = size - index - 1; if (numMoved > 0) System.arraycopy(elementData, index + 1, elementData, index, numMoved); elementData[--size] = 0; // Forget the item completely return oldValue; }
/** * Returns the element at the specified position in this list. * * @param index index of the element to return * @return the element at the specified position in this list * @throws IndexOutOfBoundsException {@inheritDoc} */ @Override public Float get(int index) { rangeCheck(index); return elementData(index); }