- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
The addAll() method of AbstractList class in Java
The addAll() method of the AbstractList class is used to insert all of the elements in the specified collection into this list at the specified position.
The syntax is as follows
boolean addAll(int index, Collection<? extends E> c)
Here, the parameter index is the index at which the first element would be inserted, whereas c is the collection containing elements to be added to this list.
To work with the AbstractList class, import the following package
import java.util.AbstractList;
The following is an example to implement addAll() method of the AbstractlList class in Java
Example
import java.util.ArrayList; import java.util.AbstractList; public class Demo { public static void main(String[] args) { AbstractList<Integer> myList = new ArrayList<Integer>(); myList.add(75); myList.add(100); myList.add(150); myList.add(200); myList.add(250); myList.add(150); myList.add(150); myList.add(400); System.out.println("Elements in AbstractList1 = " + myList); AbstractList<Integer> myList2 = new ArrayList<Integer>(); myList2.add(3); myList2.add(5); myList2.add(6); myList2.add(8); System.out.println("Elements in AbstractList2 = " + myList2); System.out.println("Inserting elements = " + myList.addAll(3, myList2) ); System.out.println("Updated AbstractList after index 3 = " + myList); } }
Output
Elements in AbstractList1 = [75, 100, 150, 200, 250, 150, 150, 400] Elements in AbstractList2 = [3, 5, 6, 8] Inserting elements = true Updated AbstractList after index 3 = [75, 100, 150, 3, 5, 6, 8, 200, 250, 150, 150, 400]
- Related Articles
- The addAll() method of Java AbstractSequentialList class
- The addAll() method of Java AbstractCollection class
- The lastIndexOf() method of AbstractList class in Java
- The subList() method of AbstractList class in Java
- The indexOf() method of AbstractList class in Java
- The equals() method of AbstractList class in Java
- The clear() method of AbstractList class in Java
- The iterator() method of AbstractList class in Java
- The listIterator() method of AbstractList class in Java
- The get() method of AbstractList class in Java
- The set() method of AbstractList class in Java
- The hashCode() method of AbstractList class in Java
- The remove() method of AbstractList class in Java
- The listIterator() method AbstractList class in Java at a specified position
- What is AbstractList Class in Java?

Advertisements