Open In App
Related Articles

AbstractSequentialList addAll() Method in Java with Examples

Improve Article
Save Article
Like Article

The addAll(int index, Collection C) method of AbstractSequentialList is used to append all of the elements from the collection passed as a parameter to this function at a specific index or position of a abstract sequential list.


boolean addAll(int index, Collection C)

Parameters: This function accepts two parameters as shown in the above syntax and are described below.

  • index: This parameter is of integer datatype and specifies the position in the list starting from where the elements from the container will be inserted.
  • C: It is a collection whose elements are needed to be appended.

Return Value: The method returns TRUE if at least one action of append is performed.

Below programs illustrate the Java.util.AbstractSequentialList.addAll() method:

Example 1:


AbstractSequentialList: [Geeks, for, Geeks, 10, 20]
The new list is: [Geeks, A, Computer, Portal, for, Geeks, for, Geeks, 10, 20]

Example 2:

// Java code to illustrate boolean addAll()
import java.util.*;
import java.util.AbstractSequentialList;
public class AbstractSequentialListDemo {
    public static void main(String args[])
        // Creating an empty AbstractSequentialList
            absqlist = new LinkedList<Integer>();
        // Use add() method to add elements
        // Creating a Collection
            collect = new LinkedList<Integer>();
        // Displaying the list
        System.out.println("The AbstractSequentialList is: "
                           + absqlist);
        // Appending the collection to the list
        absqlist.addAll(1, collect);
        // Clearing the list using clear() and displaying
        System.out.println("The new list is: " + absqlist);


The AbstractSequentialList is: [10, 20, 30, 10, 20]
The new list is: [10, 1, 2, 3, 4, 5, 20, 30, 10, 20]

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 26 Nov, 2018
Like Article
Save Article
Similar Reads
Complete Tutorials