Consider the following method that is intended to modify its parameter nameList by replacing all occurrences of name with newValue.
public void replace(ArrayList nameList,
String name, String newValue)
{
for (int j = 0; j < nameList.size(); j++)
{
if ( /* expression */ )
{
nameList.set(j, newValue);
}
}
}
Which of the following can be used to replace /* expression */ so that replace will work as intended?
A) nameList.get(j).equals(name)
B) nameList.get(j) == name
C) nameList.remove(j)
D) nameList[j] == name
E) nameList[j].equals(name)