Java ArrayBlockingQueue removeAll() MethodThe removeAll() method of Java ArrayBlockingQueue class removes the elements of the ArrayBlockingQueue which are contained in the specified collection. Syntax:Parameters:Here, the parameter c is the collection containing elements to be removed from ArrayBlockingQueue. Specified By:The removeAll () method of ArrayBlockingQueue class is specified by: removeAll in interface Collection<E>. Return Value:The removeAll () method returns a Boolean value 'true' if the collection has changed as a result of the call, else it returns 'false'. Throws:It throws NullPointerException, if the specified collection does not support null elements or it contains one or more null elements. Example 1Output: 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 2Output: Total Patients = 6 Megha Reema Supriya Anoop Sonia Tejashvi Patients recovered and discharged : [Megha, Reema, Supriya, Anoop] Patients left in the hospital = 2 Sonia Tejashvi Example 3Output: Queue = [123, 56, 100] Exception in thread "main" java.lang.NullPointerException at java.util.Objects.requireNonNull(Objects.java:203) at java.util.AbstractCollection.removeAll(AbstractCollection.java:371) at com.javaTpoint.ArrayBlockingQueueRemoveAllExample3.main(ArrayBlockingQueueRemoveAllExample3.java:16) |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India