Homework 4
Exercise 13.x1: The following definition of a
get
method is intended to be inserted into theIntList
class. Replace the TODO comment with Java code that makes the method behave as specified. Your procedure should be efficient in the case of a small index within a long list./** * Get an element from this IntList by position. * @param index the position (counting from 0) * @return the value at that position * @throws IndexOutOfBoundsException if index not in [0,length) */ public int get(int index){ // TODO handle the non-exceptional case throw new IndexOutOfBoundsException(); }
Email your completed
IntList.java
file to me.Do Exercise 14.1 on pages 265-266 but skip the programming part. You only have to extend the two sequences given on page 266.