Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
526 B
4
Indexable
Never
Scanner scanner = new Scanner(System.in);
        System.out.println("How many elements do you want to input?");
        int arraySize = scanner.nextInt();
        ArrayList<String> inputList = new ArrayList<>();
        for(int i = 0; i < arraySize; i++){
            System.out.println("Input String");
            inputList.add(scanner.next());
        }
        System.out.println("You have inputted all the strings. The result is: ");
        for(String value: inputList){
            System.out.println(value);
        }