020-001-009
Basic ArrayList Operations
Easy
Problem Description
Basic ArrayList Operations
In this problem, you will create a method that takes three strings as arguments, adds them to an ArrayList, and returns the list size followed by all elements as a newline-separated string.
Learning Objective: Understand ArrayList creation, adding elements, size checking, and for-each loop traversal
Overview
Create a method that manages a list of strings using ArrayList<String> and returns size information along with all elements.
Specifications
- Implement the
buildListSummary(String item1, String item2, String item3)method - Create an
ArrayList<String>and add the three argument strings in order - Return a string with
"Size: " + list sizeas the first line, followed by each element separated by newlines
Input/Output Example
buildListSummary("apple", "banana", "cherry")
→ "Size: 3\napple\nbanana\ncherry"
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