AbstractCollection.containsAll(Collection<?>): This method is available in java.util.ArrayDeque class of Java.
Syntax:
boolean java.util.AbstractCollection.containsAll(Collection<?> c)
This method takes one argument. This method returns true if this collection contains all of the elements in the specified collection.
Parameters: One parameter is required for this method.
c: collection to be checked for containment in this collection.
Returns: true if this collection contains all of the elements in the specified collection.
Throws:
1. ClassCastException - if the types of one or more elements in the specified collection are incompatible with this collection.
2. NullPointerException - if the specified collection contains one or more null elements and this collection does not permit null elements(optional),or if the specified collection is null.
Approach:
Java
import java.util.ArrayDeque;public class ArrayDequecontainsAll {public static void main(String[] args) {ArrayDeque<Integer> arrayDeque =new ArrayDeque<Integer>();arrayDeque.add(1);arrayDeque.add(4);ArrayDeque<Integer> arrayDeque2 =new ArrayDeque<Integer>();arrayDeque2.add(2);arrayDeque2.add(4);System.out.println(arrayDeque.containsAll(arrayDeque2));}}
Output:
false
No comments:
Post a Comment