ArrayList removeIf() Method in Java with Examples Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article 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 More infoAdvertise with us A AmanSingh2210 Follow Improve Article Tags : Java Java-Collections Java - util package java-basics Java-Functions Java-ArrayList +2 More Practice Tags : JavaJava-Collections Explore BasicsIntroduction to Java4 min readJava Programming Basics9 min readJava Methods7 min readAccess Modifiers in Java6 min readArrays in Java9 min readJava Strings8 min readRegular Expressions in Java7 min readOOPs & InterfacesClasses and Objects in Java10 min readJava Constructors10 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface11 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java6 min readIterator in Java5 min readJava Comparator Interface6 min readException HandlingJava Exception Handling8 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 Tutorial15+ min readSynchronization in Java10 min readFile Handling in Java5 min readJava Method References9 min readJava 8 Stream Tutorial15+ min readJava Networking15+ min readJDBC Tutorial12 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 Examples8 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions7 min readJava Quiz | Level Up Your Java Skills1 min readTop 50 Java Project Ideas For Beginners and Advanced [Update 2025]15+ min read Like