creating Strings from ints
I was wondering how i could create a number of strings for an int variable that i specify in an input.
For example i use
System.out.print("Number of users ");
numberOfUsers = input.nextInt();
say i specify the number of users to 5. I then want
String user1;
String user2;
String user3;
String user4;
String user5;
to be created
If i specify number of users to 2. I then only want
String user1;
String user2;
to be created
Heres the code i wish to apply it to. (its very Beta)
import java.util.*;
publicclass HelloWorld
{
publicstaticvoid main(String[] args)
{
int numberOfUsers;
String auth;
String pass;
String user1;
String pass1;
Scanner input =new Scanner(System.in);
//
System.out.print("Auth ");
auth = input.nextLine();
System.out.print("Pass ");
pass = input.nextLine();
System.out.print("Number of users ");
numberOfUsers = input.nextInt();
//
System.out.print("Username 1 ");
user1 = input.next();
System.out.print("Pass 1 ");
pass1 = input.next();
//
System.out.print("Your auth is " + auth);
}
}
Message was edited by:
FattyBank164

