Javatpoint Logo
Javatpoint Logo

Java ConcurrentLinkedQueue removeAll() Method

The removeAll() method of ConcurrentLinkedQueue class is used to remove the elements of the ConcurrentLinkedQueue that are matched with the items of the specified collection.



Here, the parameter c is the collection containing elements to be removed from ConcurrentLinkedQueue.

Specified By:

The removeAll () method of ConcurrentLinkedQueue class is specified by:

removeAll in interface Collection<E>.

Return Value:

The removeAll () method returns a Boolean value 'true' if the collection is changed otherwise it returns false.


It throws NullPointerException if the specified collection does not support null elements or it contains one or more null elements.

Example 1

Test it Now


Queue : [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z]
List of vowels : [A, E, I, O, U]
Queue without vowels : [B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Y, Z]

Example 2

Test it Now


Total no : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
 Even no : [2, 4, 6, 8, 10]
 Odd no : [1, 3, 5, 7, 9]

Example 3

Test it Now


Exception in thread "main" java.lang.NullPointerException
	at java.util.concurrent.ConcurrentLinkedQueue.checkNotNull(
	at java.util.concurrent.ConcurrentLinkedQueue.offer(
	at java.util.concurrent.ConcurrentLinkedQueue.add(
	at com.javaTpoint.ConcurrentLinkedQueueRemoveAllExample3.main(

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA