018-002-010

ArrayList Operations and Iteration

Hard

Problem Description

ArrayList Operations and Iteration

In this problem, you will create a program that adds and removes fruit names from an ArrayList<String>, then displays the size and all elements after each operation to standard output.

Learning Objective: Understand basic ArrayList operations (add, get, remove, size) and iteration

Overview

ArrayList can be used as a dynamic array with easy element addition, removal, and retrieval. Generics specify the element type.

Specifications

  • Add 3 fruit names to ArrayList (Apple, Banana, Cherry)
  • Display size and all elements
  • Remove the element at index 1
  • Display size and all elements after removal

Output Format

Size: 3
Apple
Banana
Cherry
Removed: Banana
Size: 2
Apple
Cherry

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up