I have an array and a method to create a list out of the values in the array.
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("enter all names separated by commas");
String allNames = scanner.nextLine();
String[] letters = {"a", "b", "c", "d"};;
convertToList(letters);
}
public static ArrayList<String> convertToList(String [] array) {
ArrayList<String> outputList = new ArrayList<>();
for (int i = 0; i<array.length; i++) {
outputList.add(array[i]);
}
return outputList;
}
Now, if I wanted to print a string from outputList or add a new string to it in the main method, how do I do it?