1: // @author Frank M. Carrano, Timothy M. Henry 2: // @version 5.0 3: public T replace(int givenPosition, T newEntry) 4: { 5: if ((givenPosition >= 1) && (givenPosition <= numberOfEntries)) 6: { 7: // Assertion: !isEmpty() 8: Node desiredNode = getNodeAt(givenPosition); 9: T originalEntry = desiredNode.getData(); 10: desiredNode.setData(newEntry); 11: return originalEntry; 12: } 13: else 14: throw new IndexOutOfBoundsException( 15: "Illegal position given to replace operation."); 16: } // end replace