AbstractSequentialList in Java with Examples - GeeksforGeeks

11 Nov, 2020
The AbstractSequentialList class in Java is a part of the Java Collection Framework and implements the Collection interface and the AbstractCollection class. It is used to implement an unmodifiable list, for which one needs to only extend this AbstractList Class and implement only the get() and the size() methods.
This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a “sequential access” data store (such as a linked list). For random access data (such as an array), AbstractList should be used in preference to this class.
Class Hierarchy: 
Declaration: 
public abstract class AbstractSequentialList<E>
    extends AbstractList<E>

Where E is the type of element maintained by this List.


It implements Iterable<E>, Collection<E>, List<E> interfaces. LinkedList is the only direct subclass of AbstractSequentialList.
Constructor: protected AbstractSequentialList() – The default constructor, but being protected, it doesn’t allow to create an AbstractSequentialList object.
AbstractSequentialList<E> asl = new LinkedList<E>();  
Example 1:  AbstractSequentialList is an abstract class, so it should be assigned an instance of its subclass such as LinkedList. 
Java
// Java code to illustrate AbstractSequentialListimport java.util.*;  public class GfG {      public static void main(String[] args)    {        // Creating an instance of        // the AbstractSequentialList        AbstractSequentialList<Integer> absl            = new LinkedList<>();          // adding elements to absl        absl.add(5);        absl.add(6);        absl.add(7);          // Printing the list        System.out.println(absl);    }}
Output:
[5, 6, 7]

Example 2:   
Java
// Java code to illustrate// methods of AbstractSequentialList  import java.util.*;import java.util.AbstractSequentialList;  public class AbstractSequentialListDemo {    public static void main(String args[])    {          // Creating an empty AbstractSequentialList        AbstractSequentialList<String>            absqlist = new LinkedList<String>();          // Using add() method to          // add elements in the list        absqlist.add("Geeks");        absqlist.add("for");        absqlist.add("Geeks");        absqlist.add("10");        absqlist.add("20");          // Output the list        System.out.println("AbstractSequentialList: "                           + absqlist);          // Remove the head using remove()        absqlist.remove(3);          // Print the final list        System.out.println("Final List: "                           + absqlist);          // Fetching the specific           // element from the list        // using get() method        System.out.println("The element is: "                           + absqlist.get(2));    }}
Output:
AbstractSequentialList: [Geeks, for, Geeks, 10, 20]
Final List: [Geeks, for, Geeks, 20]
The element is: Geeks

METHOD
DESCRIPTION
METHOD
DESCRIPTION
METHOD
DESCRIPTION
METHOD
DESCRIPTION
METHOD
DESCRIPTION
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).
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.
Reference: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/AbstractSequentialList.html 
Ganeshchowdharysadanala
Java - util package
java-AbstractSequentialList
Java-Collections
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Java
Split() String method in Java with examples
For-each loop in Java
Arrays.sort() in Java with examples
Reverse a string in Java
Initialize an ArrayList in Java
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Interfaces in Java
ArrayList in Java