Close

Java Collections - ArrayBlockingQueue.removeAll() Examples

Java Collections Java Java API 


Class:

java.util.concurrent.ArrayBlockingQueue

java.lang.Objectjava.lang.Objectjava.util.AbstractCollectionjava.util.AbstractCollectionjava.util.CollectionCollectionjava.util.AbstractQueuejava.util.AbstractQueuejava.util.QueueQueuejava.util.concurrent.ArrayBlockingQueuejava.util.concurrent.ArrayBlockingQueuejava.util.concurrent.BlockingQueueBlockingQueuejava.io.SerializableSerializableLogicBig

Method:

public boolean removeAll(Collection<?> c)

Removes all of this collection's elements that are also contained in the specified collection. After this call returns, this collection will contain no elements in common with the specified collection.


Examples


package com.logicbig.example.arrayblockingqueue;

import java.util.Arrays;
import java.util.concurrent.ArrayBlockingQueue;

public class RemoveAllExample {

public static void main(String... args) {
ArrayBlockingQueue<Integer> q = new ArrayBlockingQueue<>(3, true, Arrays.asList(1, 3, 5));
System.out.println("queue before: " + q);

boolean b = q.removeAll(Arrays.asList(1, 5, 7));
System.out.println(b);
System.out.println("queue after: " + q);
}
}

Output

queue before: [1, 3, 5]
true
queue after: [3]




See Also