Indexes for a list start at 0, just as do arrays.
List<E>
Interface
Here is a summary of the List<E>
Interface.
For the full interface see your Java documentation.
java.util Interface List<E> boolean add(E elt) Appends element elt to the end of the list. void add(int index, E elt) Inserts element elt at the specified index. E get(int index) Returns a reference to the element at the specified index. int indexOf(Object elem) Searches for the first occurence of elem, testing for equality using the equals(Object) method. E set(int index, E elt) Replaces the element at index with the specified element elt. . . . many others . . .
The methods are described in terms of the type
reference to E
that the list contains.
Say that you have an ArrayList
of references to String
.
What does the add()
method look like?