1, using the original for loop
for (int I = 0; I <intList.size (); I ++) { IF (intList.het (I) 13 is ==) { intList.remove (I); I -; // updated to delete the contents on the set, leading to a final point to be empty. So the loop variable - can be. } }
2, using an iterator (the official recommended)
Iterator <Integer> = intList.iterator IT (); WHERE (it.hasNext ()) { IF (it.next () == 13 is) {//it.next () method to return the current element it.remove ( ); }