Hi there,

So I am trying to make a program that will allow me to input multiple users and be able to store data under their names.
My problem is that I don't know how to make it so that the user can input as many names as he/she wants to.
I created a while loop that stated that until the user typed in "n", it would keep asking to add names but I don't know where or how I would be able to store those names.

Here is the code that I have so far (I know it's not finished and there are still some mistakes):

import java.util.Scanner;

public class SheetCounter 
{
    static Scanner userin = new Scanner (System.in);
    public static void Main (String[] args)
    {
        System.out.println("Welcome to the -----");
        System.out.println("Please input the name of a user you wish to add:");
        String EmployeeA = userin.nextLine();
        int a = 0;
        while (a == 0)
        {
            System.out.println("Please input the name of another user you wish to user");
            System.out.println("If you do not have any more user to add, please type n:");
            String EmployeeB = userin.nextLine();
            if (EmployeeB.equals("n"))
            {
                a = 1;
            }
        }
        System.out.println("Ok, so you have added");

    }
}

Never mind, I realized that I could have used Array Lists (such a dummy right?)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.