ArrayList removeIf() Method in Java with Examples Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 14 Likes Like Report The Java ArrayList removeIf() method is used to remove all elements from the ArrayList that satisfy a given predicate filter. The predicate is passed as a parameter to the method, and any runtime exceptions thrown during iteration or by the predicate are passed to the caller.The removeIf() method uses Java 8's Predicate functional interface to apply conditions for removing elements.Example 1: Here, we use the removeIf() method to remove numbers divisible by 3 from an ArrayList of integers. Java // Java program to demonstrate the use of removeIf() // method with ArrayList of Integers import java.util.ArrayList; public class GFG { public static void main(String[] args) { // create an ArrayList of integers ArrayList<Integer> num = new ArrayList<>(); // Adding numbers to // the ArrayList num.add(23); num.add(32); num.add(45); num.add(63); // Using removeIf() method to remove // numbers divisible by 3 num.removeIf(n -> (n % 3 == 0)); System.out.println(num); } } Output[23, 32] Syntax of ArrayList removeIf() Methodboolean removeIf(Predicate filter)Parameter: This method takes a parameter "filter" that specifies the condition for removing elements. Return Type: This method returns true if any elements were removed; otherwise, false. Exception: This method throws NullPointerException if the specified filter is null. Other Examples of Java ArrayList removeIf() MethodExample 2: Here, we use the removeIf() method to remove names starting with the letter 'S' from an ArrayList of strings. Java // Java program to demonstrate the use of removeIf() // method with ArrayList of Strings import java.util.ArrayList; public class GFG { public static void main(String[] args) { // Creating an ArrayList of student names ArrayList<String> s = new ArrayList<>(); // Adding student names to the ArrayList s.add("Sweta"); s.add("Gudly"); s.add("Sohan"); s.add("Amiya"); s.add("Ram"); // Using removeIf() method to // remove names starting with 'S' s.removeIf(name -> name.startsWith("S")); System.out.println("Students whose names do not start with S:"); System.out.println(s); } } OutputStudents whose names do not start with S: [Gudly, Amiya, Ram] Comment A AmanSingh2210 Follow 14 Improve A AmanSingh2210 Follow 14 Improve Article Tags : Java Java-Collections Java - util package java-basics Java-Functions Java-ArrayList +2 More Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings8 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java9 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java5 min readJava Comparator Interface6 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java10 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management4 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like