In this specific case, you should remove the elements in descending order. First index 5
, then 3
, then 1
. This will remove the elements from the list without undesirable side effects.
for (int j = i.length-1; j >= 0; j--) {
list.remove(i[j]);
}
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?
- Java ArrayList – how can I tell if two lists are equal, order not mattering?
- Retrieving a random item from ArrayList [duplicate]
- Understand Arraylist IndexOutOfBoundsException in Android
- How can I calculate the difference between two ArrayLists?
- Time complexity for java ArrayList
- How to create an 2D ArrayList in java? [duplicate]
- In Java 8, why is the default capacity of ArrayList now zero?
- Java ArrayList replace at specific index
- What is a List vs. an ArrayList? [duplicate]
- Remove objects from an ArrayList based on a given criteria
- 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()?