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