020-001-006

Collections: ArrayList Basic Operations

Medium

Problem Description

In this problem, you will create a program that adds integers to an ArrayList, outputs the size and all elements in order, removes the first element, and displays the final size to standard output.

Collections: ArrayList Basic Operations

Learning Objective: Understand basic ArrayList operations like add, get, and remove

Overview

ArrayList is a collection class providing variable-length arrays. It allows easy addition and removal of elements without worrying about array size.

Specifications

Create a program to manage a list of integers.

  • First input: Number of elements n to add to list
  • Next n inputs: Integer values to add to list
  • Output list size
  • Output all list elements in order (one element per line)
  • Remove first element
  • Output size after removal

Input Format

<count>
<integer1>
<integer2>
...

Output Format

Size: <size>
<element1>
<element2>
...
After removal: <size after removal>

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