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

Author Question: Suppose an ArrayList list contains {"red", "red", "green"}. What is the list after the following ... (Read 29 times)

fnuegbu

  • Hero Member
  • *****
  • Posts: 539

Question 1

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

list.remove("red");

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

Question 2

Suppose an ArrayList list contains {"red", "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);

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


Related Topics

Need homework help now?

Ask unlimited questions for free

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

kxciann

  • Sr. Member
  • ****
  • Posts: 356
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




fnuegbu

  • Member
  • Posts: 539
Reply 2 on: May 6, 2020
YES! Correct, THANKS for helping me on my review


ashely1112

  • Member
  • Posts: 347
Reply 3 on: Yesterday
Great answer, keep it coming :)

 

Did you know?

In the ancient and medieval periods, dysentery killed about ? of all babies before they reach 12 months of age. The disease was transferred through contaminated drinking water, because there was no way to adequately dispose of sewage, which contaminated the water.

Did you know?

Critical care patients are twice as likely to receive the wrong medication. Of these errors, 20% are life-threatening, and 42% require additional life-sustaining treatments.

Did you know?

Computer programs are available that crosscheck a new drug's possible trade name with all other trade names currently available. These programs detect dangerous similarities between names and alert the manufacturer of the drug.

Did you know?

A recent study has found that following a diet rich in berries may slow down the aging process of the brain. This diet apparently helps to keep dopamine levels much higher than are seen in normal individuals who do not eat berries as a regular part of their diet as they enter their later years.

Did you know?

Patients who cannot swallow may receive nutrition via a parenteral route—usually, a catheter is inserted through the chest into a large vein going into the heart.

For a complete list of videos, visit our video library