This topic contains a solution. Click here to go to the answer

Author Question: Suppose a list contains {"red", "green", "red", "green"}. What is the list after the following code? ... (Read 105 times)

kshipps

  • Hero Member
  • *****
  • Posts: 571

Question 1

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

list.remove("red");

◦ {"red", "green", "red", "green"}
◦ {"red", "green", "green"}
◦ {"green", "red", "green"}
◦ {"green", "green"}

Question 2

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

String element = "red";
for (int i = 0; i < list.size(); i++)
if (list.get(i).equals(element)) {
list.remove(element);
i--;
}

◦ {"red", "red", "green"}
◦ {}
◦ {"green"}
◦ {"red", "green"}


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by kshipps on May 6, 2020

sarahccccc

  • Sr. Member
  • ****
  • Posts: 318
Lorsum iprem. Lorsus sur ipci. Lorsem sur iprem. Lorsum sur ipdi, lorsem sur ipci. Lorsum sur iprium, valum sur ipci et, vala sur ipci. Lorsem sur ipci, lorsa sur iprem. Valus sur ipdi. Lorsus sur iprium nunc, valem sur iprium. Valem sur ipdi. Lorsa sur iprium. Lorsum sur iprium. Valem sur ipdi. Vala sur ipdi nunc, valem sur ipdi, valum sur ipdi, lorsem sur ipdi, vala sur ipdi. Valem sur iprem nunc, lorsa sur iprium. Valum sur ipdi et, lorsus sur ipci. Valem sur iprem. Valem sur ipci. Lorsa sur iprium. Lorsem sur ipci, valus sur iprem. Lorsem sur iprem nunc, valus sur iprium.
Answer Preview
Only 50% of students answer this correctly




kshipps

  • Member
  • Posts: 571
Reply 2 on: May 6, 2020
Wow, this really help


CAPTAINAMERICA

  • Member
  • Posts: 325
Reply 3 on: Yesterday
YES! Correct, THANKS for helping me on my review

 

Did you know?

The types of cancer that alpha interferons are used to treat include hairy cell leukemia, melanoma, follicular non-Hodgkin's lymphoma, and AIDS-related Kaposi's sarcoma.

Did you know?

Cocaine was isolated in 1860 and first used as a local anesthetic in 1884. Its first clinical use was by Sigmund Freud to wean a patient from morphine addiction. The fictional character Sherlock Holmes was supposed to be addicted to cocaine by injection.

Did you know?

The U.S. Preventive Services Task Force recommends that all women age 65 years of age or older should be screened with bone densitometry.

Did you know?

As many as 28% of hospitalized patients requiring mechanical ventilators to help them breathe (for more than 48 hours) will develop ventilator-associated pneumonia. Current therapy involves intravenous antibiotics, but new antibiotics that can be inhaled (and more directly treat the infection) are being developed.

Did you know?

There are more nerve cells in one human brain than there are stars in the Milky Way.

For a complete list of videos, visit our video library