AbstractSequentialList in Java


The Java Collection Framework contains the AbstractSequentialList class. This class is used to create and implement an unmodifiable list. Also this class implements the Collection interface and the AbstractCollection class.

A program that demonstrates this is given as follows −

Example

 Live Demo

import java.util.*;
public class Demo {
   public static void main(String[] args) {
      AbstractSequentialList<String> list = new LinkedList<>();
      list.add("John");
      list.add("Martha");
      list.add("Sally");
      list.add("Susan");
      list.add("Harry");
      System.out.println("The elements are: " + list);
   }
}

The output of the above program is as follows −

Output

The elements are: [John, Martha, Sally, Susan, Harry]

Now let us understand the above program.

The AbstractSequentialList class implements an unmodifiable list. The list elements are displayed. A code snippet that demonstrates this is given as follows −

AbstractSequentialList<String> list = new LinkedList<>();
list.add("John");
list.add("Martha");
list.add("Sally");
list.add("Susan");
list.add("Harry");
System.out.println("The elements are: " + list);

Updated on: 30-Jul-2019

62 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements