top of page

8.23.2024

Aug 22

1 min read

0

3

0

//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


video explanation

Aug 22

1 min read

0

3

0

Comments

Share Your ThoughtsBe the first to write a comment.
bottom of page