015-004-006
Basic ArrayList Operations
Easy
Problem Description
Basic ArrayList Operations
In this problem, you will create a program that reads N strings from standard input, adds them to an ArrayList<String> in order, and displays all elements to standard output using an enhanced for loop.
Learning Objective: Understand basic operations of dynamic array ArrayList (add, get, size)
Overview
Create a program that reads data from standard input, adds elements to ArrayList, and outputs all elements in a loop.
Input Format
N
string1
string2
...
stringN
- Line 1: number of elements N (1 ≤ N ≤ 100)
- Lines 2 to N+1: N strings
Output Format
string1
string2
...
stringN
Example
Input:
3
Apple
Banana
Cherry
Output:
Apple
Banana
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