- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 removeAll() method of AbstractSequentialList in Java
The removeAll() is a method inherited from AbstractCollection class. It removes all the elements of this collection that are also contained in the specified collection.
The syntax is as follows:
public boolean removeAll(Collection<?> c)
Here, the parameter c is the collection having elements to be removed from this collection.
To work with the AbstractSequentialList class in Java, you need to import the following package:
import java.util.AbstractSequentialList;
The following is an example to implement AbstractSequentialList removeAll() method in Java:
Example
import java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] args) { AbstractSequentialList<Integer> absSequential = new LinkedList<>(); absSequential.add(210); absSequential.add(290); absSequential.add(350); absSequential.add(490); absSequential.add(540); absSequential.add(670); absSequential.add(870); System.out.println("Elements in the AbstractSequentialList1 = "+absSequential); AbstractSequentialList<Integer> absSequential2 = new LinkedList<>(); absSequential2.add(670); absSequential2.add(870); System.out.println("Elements in the AbstractSequentialList2 = "+absSequential2); absSequential.removeAll(absSequential2); System.out.println("Elements in the updated AbstractSequentialList1 = "+absSequential); } }
Output
Elements in the AbstractSequentialList1 = [210, 290, 350, 490, 540, 670, 870] Elements in the AbstractSequentialList2 = [670, 870] Elements in the updated AbstractSequentialList1 = [210, 290, 350, 490, 540]
Advertisements