Data Structures, Algorithms, & Applications in Java
Chapter 5, Exercise 7

The method dataStructures.ArrayLinearListWithSet.set is given below.
/** set the element whose index is theIndex to theElement
  * @throws IndexOutOfBoundsException when theIndex < 0
  * or theIndex >= size 
  * @returns old element with index equal to theIndex */
public Object set(int theIndex, Object theElement)
{
   checkIndex(theIndex);
   Object elementToReturn = element[theIndex];
   element[theIndex] = theElement;
   return elementToReturn;
}