Signup/Sign In

Abstract Sequential list


In Java, AbstractSequentialList class is the part of the Java Collection Framework. The Abstract Sequential list is implemented by the collection interface and the Abstract Collection class. This is used when the list can not be modified. To implement this AbstractList class is used with get() and size() methods.


Below is the class Hierarchy

abstract-sequential-list.JPG

Syntax:

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

Below are the methods of AbstractSequentialList Class


S.no. Method Description
1 add(int index, E element) It is used to add an element at the specified position of the list.
2 addAll(int index, Collection c) It is used to add an element at the specified collection at the specified position of the list.
3 get(int index) It is used to get the element from the specified position in the list.
4 Iterator() It returns all the elements from the list. Using Iterator.
5 listIterator() It is used to get the Iterated list in a proper sequence.
6 remove(int index) It is used to remove the specified element from the list.
7 set(int index, E element) It is used to replace an element from the specified element.

Example:

	
import java.util.*; 
public class AbstractSequentialListDemo1 { 
    public static void main(String[] args) 
    { 
AbstractSequentialList<Integer> a = new LinkedList<>(); 
a.add(1); 
a.add(2); 
a.add(3); 
a.add(4);         
a.add(5); 
a.add(6); 
System.out.println("List = "+a); 
	System.out.println("************************************");
	System.out.println("The 2nd elements in the List is: "+ a.get(2)); 
	System.out.println("************************************");
	System.out.println("Remove 3rd element from the list: "+a.remove(3));    
	System.out.println("************************************");
	System.out.println("List = "+a); 
    } 
}
	

abstract-sequential-list-example