You can use Collection::removeIf(Predicate filter) (available from Java8 onwards), here is a simple example:
final Collection<Integer> list = new ArrayList<>(Arrays.asList(1, 2));
list.removeIf(value -> value < 2);
System.out.println(list); // outputs "[2]"
More Related Contents:
- How to convert ArrayList to String[][]?
- How to move elements of Java ArrayList to file in java [closed]
- ArrayList with 2 dimensions [closed]
- Initialization of an ArrayList in one line
- How to avoid “ConcurrentModificationException” while removing elements from `ArrayList` while iterating it? [duplicate]
- How to create a Multidimensional ArrayList in Java?
- Retrieving a random item from ArrayList [duplicate]
- How to make a deep copy of Java ArrayList [duplicate]
- How do I clone a generic List in Java?
- Stream Filter of 1 list based on another list
- How to create an 2D ArrayList in java? [duplicate]
- In Java 8, why is the default capacity of ArrayList now zero?
- Add multiple items to an already initialized arraylist in Java
- Creating an Arraylist of Objects
- How to use invokeAll() to let all thread pool do their task?
- ArrayList.remove is not working in a loop
- Most efficient way to see if an ArrayList contains an object in Java
- Load arrayList data into JTable
- Using contains on an ArrayList with integer arrays
- Sum all the elements java arraylist
- ArrayList contains case sensitivity
- What is the Simplest Way to Reverse an ArrayList?
- Create an ArrayList with multiple object types?
- Java ArrayList Contain always return false although it contain the same value
- Sorting ArrayList of Objects by Object attribute
- Converting an ArrayList into a 2D Array
- Better way to find index of item in ArrayList?
- Java generics – ArrayList initialization
- How to pass ArrayList using putStringArrayListExtra()
- What is the difference between ArrayList.clear() and ArrayList.removeAll()?