Suppose a list contains red red red red what is the list


Suppose a list contains {red, red, red, red}. What is the list after the following code?

String element = "red";
for (int i = list.size() - 1; i >= 0; i--)
if (list.get(i).equals(element))
list.remove(element);
A. [red]
B. [red, red, red]
C. [red, red]
D. []

 

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Suppose a list contains red red red red what is the list
Reference No:- TGS01384831

Now Priced at $20 (50% Discount)

Recommended (99%)

Rated (4.3/5)