020-001-007

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 them as a newline-separated string.

Learning Objective: Understand basic operations for adding and retrieving elements using ArrayList

Overview

ArrayList is a class for handling variable-length arrays. It allows operations such as adding, retrieving, and removing elements, making it more flexible than regular arrays.

Specifications

  1. Implement the createFruitList(String fruit1, String fruit2, String fruit3) method
  2. Create an ArrayList of String type and add the three argument strings
  3. Return all elements joined by newlines

Input/Output Example

createFruitList("Apple", "Banana", "Orange")
→ "Apple\nBanana\nOrange"

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