020-001-012
ArrayList Basic Operations
Easy
Problem Description
ArrayList Basic Operations
In this problem: You will use basic ArrayList operations (add/get/size) to manage a list of strings and display results to standard output.
Learning Objective: Understand basic add, get, and size operations of ArrayList
Overview
ArrayList is a resizable array that makes it easy to add and retrieve elements. Unlike fixed-size arrays, it automatically expands as elements are added.
Specifications
- Create an
ArrayList<String> - Use
addto add"Java","Python","JavaScript" - Display list size with
size() - Display elements with
get(0)andget(2) - Insert
"C++"at index 1 withadd(1, "C++") - Display the final list contents
Output Format
Size: 3
First: Java
Last: JavaScript
After insert: [Java, C++, Python, JavaScript]
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