1: public T replace(int givenPosition, T newEntry) 2: { 3: checkInitialization(); 4: if ((givenPosition >= 1) && (givenPosition <= numberOfEntries)) 5: { 6: assert !isEmpty(); 7: T originalEntry = list[givenPosition]; 8: list[givenPosition] = newEntry; 9: return originalEntry; 10: } 11: else 12: throw new IndexOutOfBoundsException( 13: "Illegal position given to replace operation."); 14: } // end replace 15: public T getEntry(int givenPosition) 16: { 17: checkInitialization(); 18: if ((givenPosition >= 1) && (givenPosition <= numberOfEntries)) 19: { 20: assert !isEmpty(); 21: return list[givenPosition]; 22: } 23: else 24: throw new IndexOutOfBoundsException( 25: "Illegal position given to getEntry operation."); 26: } // end getEntry 27: // Version 4.0