Use an Iterator
and call remove()
:
Iterator<String> iter = myArrayList.iterator();
while (iter.hasNext()) {
String str = iter.next();
if (someCondition)
iter.remove();
}
More Related Contents:
- How to arrange the datas to display in array by given string of days in java?
- How to create a Java ArrayList in C
- ArrayList, Loop and requisite if can not work that i want – Java 11
- Why does my ArrayList contain N copies of the last item added to the list?
- How do I remove repeated elements from ArrayList?
- Why do I get an UnsupportedOperationException when trying to remove an element from a List?
- How to sort a List/ArrayList?
- Convert list to array in Java [duplicate]
- Java List.add() UnsupportedOperationException
- In Java how do you sort one list based on another?
- How to randomize two ArrayLists in the same fashion?
- What is the difference between List and ArrayList? [duplicate]
- Performance of traditional for loop vs Iterator/foreach in Java
- List versus ArrayList as reference type?
- Modifier static is only allowed in constant variable declarations
- Difference between Iterator and Listiterator?
- How to get a reversed list view on a list in Java?
- Simple way to compare 2 ArrayLists
- What is a List vs. an ArrayList? [duplicate]
- Convert Iterator to List
- Removing Duplicate Values from ArrayList
- Why can’t you have a “List” in Java? [duplicate]
- ArrayList vs LinkedList from memory allocation perspective
- Finding out if a list of Objects contains something with a specified field value?
- new ArrayList() failing in Java
- How to remove common values from two array lists
- list.clear() vs list = new ArrayList(); [duplicate]
- make arrayList.toArray() return more specific types
- Create an ArrayList with multiple object types?
- Java ArrayList Contain always return false although it contain the same value