Skip to main content

Section 5.2 Starter Level

Subsection 5.2.1 Instructions

  1. Initialize an ArrayList and add the following elements: "Butter", "Milk", "Cookies", "Chips", "Carrots".
  2. Remove the third item from the list.
  3. Replace the second item in the list with "Pancakes"
  4. Remove the last item from the list
  5. Add "Apples" to the list
  6. Print the size of the list
  7. Print the contents of the list using a for-loop.
The expected output is:
Size of the list: 3
Contents of the list:
Butter
Milk
Chips
Apples
You have attempted of activities on this page.