A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/java/abstractsequentiallist-addall-method-in-java-with-examples/ below:

AbstractSequentialList addAll() Method in Java with Examples

AbstractSequentialList addAll() Method in Java with Examples

Last Updated : 11 Jul, 2025

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.

Syntax:
boolean addAll(int index, Collection C)
Parameters:

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

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: Java
// Java code to illustrate addAll() method

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>();

        // Use add() method to add elements
        absqlist.add("Geeks");
        absqlist.add("for");
        absqlist.add("Geeks");
        absqlist.add("10");
        absqlist.add("20");

        // Creating a Collection
        Collection<String>
            collect = new ArrayList<String>();
        collect.add("A");
        collect.add("Computer");
        collect.add("Portal");
        collect.add("for");
        collect.add("Geeks");

        // Displaying the list
        System.out.println("AbstractSequentialList: "
                           + 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);
    }
}
Output:
AbstractSequentialList: [Geeks, for, Geeks, 10, 20]
The new list is: [Geeks, A, Computer, Portal, for, Geeks, for, Geeks, 10, 20]
Example 2: Java
// 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
        AbstractSequentialList<Integer>
            absqlist = new LinkedList<Integer>();

        // Use add() method to add elements
        absqlist.add(10);
        absqlist.add(20);
        absqlist.add(30);
        absqlist.add(10);
        absqlist.add(20);

        // Creating a Collection
        Collection<Integer>
            collect = new LinkedList<Integer>();
        collect.add(1);
        collect.add(2);
        collect.add(3);
        collect.add(4);
        collect.add(5);

        // 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);
    }
}
Output:
The AbstractSequentialList is: [10, 20, 30, 10, 20]
The new list is: [10, 1, 2, 3, 4, 5, 20, 30, 10, 20]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4