Question: Consider the following method intended to modify the parameter names by removing all instances of the String n. public static void removeNames (ArrayList names, String
Consider the following method intended to modify the parameter names by removing all instances of the String n.
public static void removeNames (ArrayListnames, String n) { for (/* Missing Code */) { if (names.get(i).equals(n)) { names.remove(i); } } }
Which of the following could correctly replace /* Missing Code */ so that removeNames works as intended?
int i = names.size() - 1; i >= 9; i++
int i = 0; i < names.size(); i--
int i = 0; i < names.size(); i++
int i = names.size() - 1; i >= 0; i--
None of the above. The code has an error.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
