T
- The type of items that the list stores.public interface List<T>
extends java.lang.Iterable<T>
Modifier and Type | Method and Description |
---|---|
void |
add(int newPosition,
T newItem)
Adds newItem at the given index.
|
void |
add(T newItem)
Adds newItem to the end of the list.
|
T |
at(int position)
Returns the item at a given index.
|
void |
clear()
Removes all items from the list.
|
boolean |
contains(T targetItem)
Returns true if the list contains the target item.
|
boolean |
isEmpty()
Returns true if the list is empty.
|
java.util.Iterator<T> |
iterator()
Returns an iterator that begins just before index 0 in this list.
|
int |
length()
Returns the length of the list.
|
T |
remove(int position)
Removes the item at the given index, and returns it.
|
void |
replace(int position,
T newItem)
Replaces the item at a given index.
|
java.lang.Object[] |
toArray()
Returns an array version of the list.
|
void add(T newItem)
void add(int newPosition, T newItem)
java.lang.IndexOutOfBoundsException
- if newPosition is out of bounds. For
this method (and only this method), the length of the list is
considered in bounds.T remove(int position)
java.lang.IndexOutOfBoundsException
- if position is out of bounds.T at(int position)
java.lang.IndexOutOfBoundsException
- if position is out of bounds.void replace(int position, T newItem)
java.lang.IndexOutOfBoundsException
- if position is out of bounds.boolean contains(T targetItem)
int length()
boolean isEmpty()
void clear()
java.lang.Object[] toArray()