VOOZH about

URL: https://www.geeksforgeeks.org/java/copyonwritearraylist-removeif-method-in-java-with-examples/

⇱ CopyOnWriteArrayList removeIf() method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

CopyOnWriteArrayList removeIf() method in Java with Examples

Last Updated : 11 Jul, 2025
The removeIf() method of CopyOnWriteArrayList removes the element from this CopyOnWriteArrayList that satisfies the specified condition. Syntax:
public boolean removeIf (Predicate<E> filter)
Parameters: This method accepts a mandatory parameter filter which is the predicate value based on which elements are removed from this List. Return Value: This method returns a boolean value such as true, if the CopyOnWriteArrayList is changed. Else this method returns false. Exceptions: This method throws NullPointerException if the specified Predicate filter is null. Below program illustrates the removeIf() function of CopyOnWriteArrayList class :
Output:
CopyOnWriteArrayList: [2, 3, 4, 7, 6, 9]
Updated CopyOnWriteArrayList: [2, 4, 7]
Output:
CopyOnWriteArrayList: [GeeksforGeeks, GFG, Geeks, Gfg]
java.lang.NullPointerException
Reference: https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/CopyOnWriteArrayList.html#removeIf-java.util.function.Predicate-
Comment