# Class AbstractSequentialList<E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<E>

All Implemented Interfaces:
  `Iterable<E>, Collection<E>, List<E>`

Direct Known Subclasses:
  `LinkedList`

public abstract class AbstractSequentialList<E> extends AbstractList<E>

AbstractSequentialList is an abstract implementation of the List interface. This implementation does not support adding. A subclass must implement the abstract method listIterator().

##### Since

1.2

- ## Field Summary

  ### Fields inherited from class AbstractList

  `modCount`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `AbstractSequentialList()`
  Constructs a new instance of this AbstractSequentialList.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(int location, E object)`
  Inserts the specified object into this List at the specified location.
  `boolean`
  `addAll(int location, Collection<? extends E> collection)`
  Inserts the objects in the specified Collection at the specified location in this List.
  `E`
  `get(int location)`
  Returns the element at the specified location in this list.
  `Iterator<E>`
  `iterator()`
  Returns an iterator on the elements of this list.
  `abstract ListIterator<E>`
  `listIterator(int location)`
  Returns a list iterator on the elements of this list.
  `E`
  `remove(int location)`
  Removes the object at the specified location from this list.
  `E`
  `set(int location, E object)`
  Replaces the element at the specified location in this list with the specified object.

  ### Methods inherited from class AbstractList

  `add, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subList, toArray, toArray`

  ### Methods inherited from class AbstractCollection

  `addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toString`

  ### Methods inherited from class Object

  `clone, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface Collection

  `removeIf`

  ### Methods inherited from interface Iterable

  `forEach`

  ### Methods inherited from interface List

  `addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, size, sort`

- ## Constructor Details

  - ### AbstractSequentialList

    protected AbstractSequentialList()
    Constructs a new instance of this AbstractSequentialList.

- ## Method Details

  - ### add

    public void add(int location, E object)
    Description copied from class: `AbstractList`

    Inserts the specified object into this List at the specified location. The object is inserted before any previous element at the specified location. If the location is equal to the size of this List, the object is added at the end.

    Concrete implementations that would like to support the add functionality must override this method.

    ###### Parameters

    - `location`: the index at which to insert.

    - `object`: the object to add.

    ###### Throws

    - `UnsupportedOperationException`: if adding to this List is not supported.

    - `ClassCastException`: @throws ClassCastException if the class of the object is inappropriate for this List

    - `IllegalArgumentException`: if the object cannot be added to this List

    - `IndexOutOfBoundsException`: if `location = size()`

    Specified by:
      `add` in interface `List<E>`
    Overrides:
      `add` in class `AbstractList<E>`

  - ### addAll

    public boolean addAll(int location, Collection<? extends E> collection)
    Description copied from class: `AbstractList`

    Inserts the objects in the specified Collection at the specified location in this List. The objects are added in the order they are returned from the collection's iterator.

    ###### Parameters

    - `location`: the index at which to insert.

    - `collection`: the Collection of objects

    ###### Returns

    `true` if this List is modified, `false` otherwise.

    ###### Throws

    - `UnsupportedOperationException`: if adding to this list is not supported.

    - `ClassCastException`: if the class of an object is inappropriate for this list.

    - `IllegalArgumentException`: if an object cannot be added to this list.

    - `IndexOutOfBoundsException`: if `location size()`

    Specified by:
      `addAll` in interface `List<E>`
    Overrides:
      `addAll` in class `AbstractList<E>`
    Returns:

      true if this `List` has been modified through the insertion, false otherwise (i.e. if the passed collection was empty).

      ###### Throws

      - `UnsupportedOperationException`: if adding to this `List` is not supported.

      - `ClassCastException`: @throws ClassCastException if the class of an object is inappropriate for this `List`.

      - `IllegalArgumentException`: if an object cannot be added to this `List`.

      - `IndexOutOfBoundsException`: if `location size()`

  - ### get

    public E get(int location)
    Description copied from class: `AbstractList`

    Returns the element at the specified location in this list.

    ###### Parameters

    - `location`: the index of the element to return.

    ###### Returns

    the element at the specified index.

    ###### Throws

    - `IndexOutOfBoundsException`: if `location = size()`
    Specified by:
      `get` in interface `List<E>`
    Specified by:
      `get` in class `AbstractList<E>`

  - ### iterator

    public Iterator<E> iterator()
    Description copied from class: `AbstractList`

    Returns an iterator on the elements of this list. The elements are iterated in the same order as they occur in the list.

    ###### Returns

    an iterator on the elements of this list.

    ###### See also

    - Iterator
    Specified by:
      `iterator` in interface `Collection<E>`
    Specified by:
      `iterator` in interface `Iterable<E>`
    Specified by:
      `iterator` in interface `List<E>`
    Overrides:
      `iterator` in class `AbstractList<E>`

  - ### listIterator

    public abstract ListIterator<E> listIterator(int location)
    Description copied from class: `AbstractList`

    Returns a list iterator on the elements of this list. The elements are iterated in the same order as they occur in the list. The iteration starts at the specified location.

    ###### Parameters

    - `location`: the index at which to start the iteration.

    ###### Returns

    a ListIterator on the elements of this list.

    ###### Throws

    - `IndexOutOfBoundsException`: if `location size()`

    ###### See also

    - ListIterator
    Specified by:
      `listIterator` in interface `List<E>`
    Overrides:
      `listIterator` in class `AbstractList<E>`

  - ### remove

    public E remove(int location)
    Description copied from class: `AbstractList`

    Removes the object at the specified location from this list.

    ###### Parameters

    - `location`: the index of the object to remove.

    ###### Returns

    the removed object.

    ###### Throws

    - `UnsupportedOperationException`: if removing from this list is not supported.

    - `IndexOutOfBoundsException`: if `location = size()`

    Specified by:
      `remove` in interface `List<E>`
    Overrides:
      `remove` in class `AbstractList<E>`

  - ### set

    public E set(int location, E object)
    Description copied from class: `AbstractList`

    Replaces the element at the specified location in this list with the specified object.

    ###### Parameters

    - `location`: the index at which to put the specified object.

    - `object`: the object to add.

    ###### Returns

    the previous element at the index.

    ###### Throws

    - `UnsupportedOperationException`: if replacing elements in this list is not supported.

    - `ClassCastException`: if the class of an object is inappropriate for this list.

    - `IllegalArgumentException`: if an object cannot be added to this list.

    - `IndexOutOfBoundsException`: if `location = size()`

    Specified by:
      `set` in interface `List<E>`
    Overrides:
      `set` in class `AbstractList<E>`