What is AbstractSequentialList class in Java?

Java 8Object Oriented ProgrammingProgramming

The AbstractSequentialList class provides an implementation of the List interface. For an unmodifiable list, implement the list iterator's hasNext, next, hasPrevious, previous and index methods. For a modifiable list the programmer should implement the list iterator's set method.

The syntax is as follows

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

To work with the AbstractSequentialList class in Java, you need to import the following package

import java.util.AbstractSequentialList;

First, create an AbstractSequentialList class

AbstractSequentialList<String> absSequential = new LinkedList<>();

Now, add elements

absSequential.add("Accessories");
absSequential.add("Home Decor");
absSequential.add("Books");
bsSequential.add("Stationery");

Let us see an example to implement the AbstractSequentialList class in Java

Example

 Live Demo

import java.util.LinkedList;
import java.util.AbstractSequentialList;
public class Demo {
   public static void main(String[] args) {
      AbstractSequentialList<String> absSequential = new LinkedList<>();
      absSequential.add("Accessories");
      absSequential.add("Home Decor");
      absSequential.add("Books");
      absSequential.add("Stationery");
      absSequential.add("Appliances");
      absSequential.add("Toys");
      System.out.println("Elements in the AbstractSequentialList = "+absSequential);
   }
}

Output

Elements in the AbstractSequentialList = [Accessories, Home Decor, Books, Stationery, Appliances, Toys]
raja
Published on 28-Mar-2019 11:41:19
Advertisements