top of page
APCSAaday.com
//Postcondition: All negative values have been removed from list.
public static void removeNegs(ArrayList<Integer> list)
{
int index - 0;
while (index < list.size())
{
if (list.get(index).intValue()< 0)
{
list.remove(index)
}
index++;
}
}
For which of the following lists will the method not work as intended?
A) 6 -1 -2 5
B) -1 2 -3 4
C) -3
D) 2 4 6 8
What is your answer? Don't forget to check out the video explanation
A
B
C
D
Related Posts
Comments
Share Your ThoughtsBe the first to write a comment.
bottom of page