- 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 containsAll() method of AbstractSequentialList in Java
The containsAll() method of the AbstractSequentialList checks for all the elements in this collection. It returns TRUE if all this collection contains all the elements in the specified collection i.e. if the two collections are same.
The syntax is as follows:
public boolean containsAll(Collection<?> c)
Here, c is the collection to be checked
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 containsAll() 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(66); absSequential.add(99); absSequential.add(140); absSequential.add(270); absSequential.add(360); absSequential.add(490); System.out.println("Elements in the AbstractSequentialList1 = "+absSequential); AbstractSequentialList<Integer> absSequential2 = new LinkedList<>(); absSequential2.add(66); absSequential2.add(99); absSequential2.add(140); absSequential2.add(270); absSequential2.add(360); absSequential2.add(490); System.out.println("Elements in the AbstractSequentialList2 = "+absSequential2); System.out.println("Both are same? = "+absSequential.containsAll(absSequential2)); } }
Output
Elements in the AbstractSequentialList1 = [66, 99, 140, 270, 360, 490] Elements in the AbstractSequentialList2 = [66, 99, 140, 270, 360, 490] Both are same? = true
Advertisements