Page 1342 - AP Computer Science A, 7th edition
P. 1342

30. (A) Method removeNegs will not work whenever there are consecutive negative values in the list. This is because removal of an element from an ArrayList causes the elements to the right of it to be shifted left to fill the “hole.” The index in the given algorithm, however, always moves one slot to the right. Therefore in choice A, when –1 is removed, –2 will be passed over, and the final list will be 6 –25.


































































































   1340   1341   1342   1343   1344