We have to read total number string i.e. "n", create a list of the Strings and input "n" strings, add then to print the all stings of the list in Java.
Declare a list of String implemented by ArrayList:
List<String> str_list = new ArrayList<String>();
To input the total number of strings and to input string from the user, we are using in which is an object of scanner class.
The statement to read string and add to the list in the loop is:
str_list.add(in.next());
Program:
Output