AbstractSequentialList in Java with Examples

Last Updated : 8 Sep, 2026

AbstractSequentialList is an abstract class in the Java Collections Framework that provides a skeletal implementation of the List interface for sequential-access data structures like linked lists. It simplifies list implementation by providing default methods.

  • Extends AbstractList and is designed for sequential access rather than random access.
  • Abstract class, so it cannot be instantiated directly.
  • For AbstractSequentialList, you must implement listIterator(int index) and size().
Java
import java.util.AbstractSequentialList;
import java.util.LinkedList;

public class GfG {

    public static void main(String[] args)
    {
        // Creating an instance of AbstractSequentialList
        AbstractSequentialList<Integer> a
            = new LinkedList<>();

        // adding elements
        a.add(5);
        a.add(6);
        a.add(7);

        // Printing the list
        System.out.println(a);
    }
}

Output
[5, 6, 7]

Java Collections Hierarchy

The diagram shows the relationship between the main interfaces, abstract classes, and implementations in the Java Collections Framework.

frame_3304

Explanation Flow

  • Collection: Root interface for storing groups of objects.
  • List: Extends Collection and maintains an ordered collection.
  • AbstractList: Provides a basic implementation of the List interface.
  • ArrayList and Vector: Extend AbstractList.
  • Stack: Extends Vector.
  • Queue: Extends Collection for queue-based operations.
  • Deque: Extends Queue and supports operations at both ends.
  • AbstractSequentialList: Extends AbstractList and is designed for sequential-access lists.
  • LinkedList: Extends AbstractSequentialList and implements Deque.

Declaration

public abstract class AbstractSequentialListextends AbstractList

Here, E represents the type of elements stored in the list.

Constructors of AbstractSequentialList

AbstractSequentialList provides a protected no-argument constructor:

AbstractSequentialList asl = new LinkedList();

Java
import java.util.AbstractSequentialList;
import java.util.LinkedList;

public class AbstractSequentialListDemo {

    public static void main(String args[])
    {

        // Creating an empty AbstractSequentialList
        AbstractSequentialList<String> a
            = new LinkedList<String>();

        // Using add() method to add elements
        a.add("Geeks");
        a.add("for");
        a.add("Geeks");
        a.add("10");
        a.add("20");

        // Output the list
        System.out.println("AbstractSequentialList: " + a);

        // Remove the head using remove()
        a.remove(3);

        // Print the final list
        System.out.println("Final List: " + a);

        // Fetching the specific element from the list
        // using get() method
        System.out.println("The element is: " + a.get(2));
    }
}

Output
AbstractSequentialList: [Geeks, for, Geeks, 10, 20]
Final List: [Geeks, for, Geeks, 20]
The element is: Geeks

Explanation

  • LinkedList is used as the concrete implementation of AbstractSequentialList.
  • The add() method adds elements to the list.
  • remove(3) removes the element at index 3, which is "10".
  • get(2) returns the element at index 2, which is "Geeks".
  • Although get() is available, AbstractSequentialList is intended for sequential-access data structures, so indexed access may require traversal.

Methods of AbstractSequentialList

METHOD

DESCRIPTION

 add​(int index, E element)Inserts the specified element at the specified position in this list (optional operation).
 addAll​(int index, Collection c)Inserts all of the elements in the specified collection into this list at the specified position (optional operation).
 get​(int index)Returns the element at the specified position in this list.
 iterator()Returns an iterator over the elements in this list (in proper sequence).
listIterator​(int index)Returns a list iterator over the elements in this list (in proper sequence).
remove​(int index)Removes the element at the specified position in this list (optional operation).
set​(int index, E element)Replaces the element at the specified position in this list with the specified element (optional operation).

Methods Inherited From class java.util.AbstractList

METHOD

DESCRIPTION

add​(E e)Appends the specified element to the end of this list (optional operation).
clear()Removes all of the elements from this list (optional operation).
equals​(Object o)Compares the specified object with this list for equality.
hashCode()Returns the hash code value for this list.
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.
lastIndexOf​(Object o)Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
listIterator()Returns a list iterator over the elements in this list (in proper sequence).
removeRange​(int fromIndex, int toIndex)Removes from this list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive.
subList​(int fromIndex, int toIndex)Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

 Methods Inherited From class java.util.AbstractCollection

METHOD

DESCRIPTION

addAll​(Collection c)Adds all of the elements in the specified collection to this collection (optional operation).
contains​(Object o)Returns true if this collection contains the specified element.
containsAll​(Collection c)Returns true if this collection contains all of the elements in the specified collection.
isEmpty()Returns true if this collection contains no elements.
remove​(Object o)Removes a single instance of the specified element from this collection, if it is present (optional operation).
removeAll​(Collection c)Removes all of this collection's elements that are also contained in the specified collection (optional operation).
 retainAll​(Collection c)Retains only the elements in this collection that are contained in the specified collection (optional operation).
 toArray()Returns an array containing all of the elements in this collection.
 toArray​(T[] a)Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
 toString()Returns a string representation of this collection.

Methods Inherited From Interface java.util.Collection

METHOD

DESCRIPTION

parallelStream()Returns a possibly parallel Stream with this collection as its source.
removeIf​(Predicate filter)Removes all of the elements of this collection that satisfy the given predicate.
stream()Returns a sequential Stream with this collection as its source.
toArray​(IntFunction generator)Returns an array containing all of the elements in this collection, using the provided generator function to allocate the returned array.

Methods Inherited From Interface java.util.List

METHODDESCRIPTION
addAll​(Collection c)

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).

contains​(Object o)Returns true if this list contains the specified element.
containsAll​(Collection c)Returns true if this list contains all of the elements of the specified collection.
isEmpty()Returns true if this list contains no elements.
remove​(Object o)Removes the first occurrence of the specified element from this list, if it is present (optional operation).
removeAll​(Collection c)Removes from this list all of its elements that are contained in the specified collection (optional operation).
replaceAll​(UnaryOperator operator)Replaces each element of this list with the result of applying the operator to that element.
retainAll​(Collection c)Retains only the elements in this list that are contained in the specified collection (optional operation).
size()Returns the number of elements in this list.
sort​(Comparator c)Sorts this list according to the order induced by the specified Comparator.
spliterator()Creates a Spliterator over the elements in this list.
toArray()Returns an array containing all of the elements in this list in proper sequence (from first to last element).
toArray​(T[] a)

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.


Comment