Names Scanner Array

44 views Asked by At

I'm trying to ask user for input as such "Enter names you'd like to list: " My first problem is that when the user enters e.g. John Bob Chris etc... Only the 1st name entered prints out.

Basically the names they enter answering that one question needs to then be listed for them using an Array.

They can enter any number of names, and that is unknown to the program until they input the amount of names they desire.

This is my code currently, I removed the import java.util.ArrayList for now just to see if the initial code is working properly which it is not.

import java.util.Scanner;
import java.util.ArrayList;

public class UserServices 
{
    public static void main(String[] args) 
    {
        Scanner input = new Scanner(System.in);

            System.out.print("Enter names you'd like to list: ");
            String names = input.nextLine();
            System.out.println("You entered: " + names );

        //Use Array, but input amount unknown

    }
}
0

There are 0 answers