Java Collections Java Java API
java.util.ArrayDeque
public boolean removeIf(Predicate<? super E> filter)
Removes all of the elements of this collection that satisfy the given predicate.
package com.logicbig.example.arraydeque;import java.util.ArrayDeque;import java.util.List;public class RemoveIfExample { public static void main(String... args) { ArrayDeque<Integer> ad = new ArrayDeque<>(List.of(3, 8, 1)); System.out.println(ad); boolean b = ad.removeIf(e -> e > 5); System.out.println(b); System.out.println(ad); }}
[3, 8, 1]true[3, 1]