The remove method for an ArrayList looks like this:
public E remove(int index)
where index is the index of the item to be deleted.
Accordingly, instead of writing
arrData.remove(arrData.get(i));
need to write delete index
arrData.remove(i);
Although once working with Integer , then arrData.remove(arrData.get(i)); it should work, but you need to know and remember: you cannot delete from the collection in the loop; you must go through the collection with an iterator , for example:
List<String> names = .... Iterator<String> i = names.iterator(); while (i.hasNext()) { String s = i.next(); if (// условие ) { i.remove(); } }
Well, either run through the collection from the end to the beginning.
As a result, it will be something like this with the iterator:
Iterator<Integer> i = arrData.iterator(); while (i.hasNext()) { Integer num = i.next(); if(num < qVal){ i.remove(); System.out.println("List-> " + num); } } System.out.println(arrData);
arrData.remove(i);. - post_zeew