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 104 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
Gracias!


epscape

  • Member
  • Posts: 335
Reply 3 on: Yesterday
Thanks for the timely response, appreciate it

 

Did you know?

Vaccines prevent between 2.5 and 4 million deaths every year.

Did you know?

The human body produces and destroys 15 million blood cells every second.

Did you know?

Signs and symptoms that may signify an eye tumor include general blurred vision, bulging eye(s), double vision, a sensation of a foreign body in the eye(s), iris defects, limited ability to move the eyelid(s), limited ability to move the eye(s), pain or discomfort in or around the eyes or eyelids, red or pink eyes, white or cloud spots on the eye(s), colored spots on the eyelid(s), swelling around the eyes, swollen eyelid(s), and general vision loss.

Did you know?

A strange skin disease referred to as Morgellons has occurred in the southern United States and in California. Symptoms include slowly healing sores, joint pain, persistent fatigue, and a sensation of things crawling through the skin. Another symptom is strange-looking, threadlike extrusions coming out of the skin.

Did you know?

If you use artificial sweeteners, such as cyclamates, your eyes may be more sensitive to light. Other factors that will make your eyes more sensitive to light include use of antibiotics, oral contraceptives, hypertension medications, diuretics, and antidiabetic medications.

For a complete list of videos, visit our video library