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 38 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
Wow, this really help


ebonylittles

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

 

Did you know?

In ancient Rome, many of the richer people in the population had lead-induced gout. The reason for this is unclear. Lead poisoning has also been linked to madness.

Did you know?

The first documented use of surgical anesthesia in the United States was in Connecticut in 1844.

Did you know?

To maintain good kidney function, you should drink at least 3 quarts of water daily. Water dilutes urine and helps prevent concentrations of salts and minerals that can lead to kidney stone formation. Chronic dehydration is a major contributor to the development of kidney stones.

Did you know?

Disorders that may affect pharmacodynamics include genetic mutations, malnutrition, thyrotoxicosis, myasthenia gravis, Parkinson's disease, and certain forms of insulin-resistant diabetes mellitus.

Did you know?

Your chance of developing a kidney stone is 1 in 10. In recent years, approximately 3.7 million people in the United States were diagnosed with a kidney disease.

For a complete list of videos, visit our video library