008-005-001
Reference Type Parameter Method: Array List Display
Easy
Problem Description
Reference Type Parameter method: array List Display
In this problem, you will create a program that defines a displayList method accepting a string array as a parameter and displays each element with a numbered prefix to standard output.
Learning Objective: Define method with reference type (array) parameter
Create program displaying all elements with numbers from string array. Pass array to displayList method.
Input
Line 1: Number of elements (integer)
Following lines: Each element (string)
Output
1. [element1]
2. [element2]
3. [element3]
...
```java
## Examples
### Example 1: 3 fruits
Input:
```java
3
apple
banana
orange
```java
Output:
```java
1. apple
2. banana
3. orange
```java
### Example 2: 4 subjects
Input:
```java
4
math
english
science
social
```java
Output:
```java
1. math
2. english
3. science
4. social
```java
### Example 3: 1 element (boundary)
Input:
```java
1
A
```java
Output:
```java
1. A
Test Cases
※ Output examples follow programming industry standards
Normal case
Input:
3 Apple Banana Orange
Expected Output:
1. Apple 2. Banana 3. Orange
Normal case
Input:
4 Math English Science Social Studies
Expected Output:
1. Math 2. English 3. Science 4. Social
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 10 free executions remaining
