The removeIf() method of ArrayDeque is used to remove all those elements from ArrayDeque which satisfies a given predicate filter condition passed as a parameter to the method. This method returns true if some element are removed from the Vector.
Java 8 has an important in-built functional interface which is Predicate. Predicate, or a condition checking function, which checks the given input for a given condition and returns a boolean result for the same indicating whether the condition was met or not.
public boolean removeIf(Predicate<? super E> filter)
Parameter: This method takes a parameter filter which represents a predicate which returns true for elements to be removed.
Returns: This method returns True if predicate returns true and some elements were removed.
Exception: This method throws NullPointerException if the specified filter is null.
Below programs illustrate removeIf() method of ArrayDeque:
Example 1: To demonstrate removeIf() method on ArrayDeque which contains a set of String and remove strings starts with A.
Students name do not starts with A Sanjeet Rabi Shabbir
Example 2: To demonstrate removeIf() method on ArrayDeque which contains set of Students objects to remove all those students who got less than 40 marks.
Students list who score above 40 Aman, 78 Amar, 79 Ankit, 76 Sanju, 62
Example 3: To demonstrate NullpointerException in removeIf() method.
- LinkedTransferQueue removeIf() method in Java with Examples
- LinkedBlockingDeque removeIf() method in Java with Examples
- CopyOnWriteArrayList removeIf() method in Java with Examples
- CopyOnWriteArraySet removeIf() method in Java with Examples
- Vector removeIf() method in Java
- ArrayList removeIf() method in Java
- ArrayDeque pop() Method in Java
- ArrayDeque contains() Method in Java
- ArrayDeque add() Method in Java
- ArrayDeque removeFirstOccurrence() Method in Java
- ArrayDeque removeLast() Method in Java
- ArrayDeque remove() Method in Java
- ArrayDeque pollLast() Method in Java
- ArrayDeque pollFirst() Method in Java
- ArrayDeque peekLast() Method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.