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