2. List Interface

Modifier and Type Method Description
boolean add(E e) Appends the specified element to the end of this list (optional operation).
void add(int index, E element) Inserts the specified element at the specified position in this list (optional operation).
E get(int index) Returns the element at the specified position in this list.
int indexOf(Object o) Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
Iterator\ iterator() Returns an iterator over the elements in this list in proper sequence.
E remove(int index) Removes the element at the specified position in this list (optional operation).
boolean remove(Object o) Removes the first occurrence of the specified element from this list, if it is present (optional operation).
E set(int index, E element) Replaces the element at the specified position in this list with the specified element (optional operation).
int size() Returns the number of elements in this list.
Object[] toArray() Returns an array containing all of the elements in this list in proper sequence (from first to last element).

image-20240103215047752