Output the list's elements

Report a typo

Here's a list of strings.

ArrayList<String> nameList = new ArrayList<>(Arrays.asList("Mr.Green", "Mr.Yellow", "Mr.Red"));

Output each of its elements in the loop. Each element must be in a new line.

Sample Input 1:

Sample Output 1:

Mr.Green
Mr.Yellow
Mr.Red
Write a program in Java 17
import java.util.*;

public class Main {
public static void main(String[] args) {
ArrayList<String> nameList = new ArrayList<>(Arrays.asList("Mr.Green", "Mr.Yellow", "Mr.Red"));
// write your code here
}
}
___

Create a free account to access the full topic