So I'm relearning java and it's been a while since. I'm trying to build a basic program (explained in code comments) and I'm having trouble remembering how to take user input and add it into an array. I'm having more trouble remembering how to loop through the user inputs and testing if they input anything as well as appending the input to the array if they do input something.
//This program will ask user for for there favorite four games
//If the answer is blank, it will ask again for a game title
//The program will than store there answers into an array
//The program will than display the array in random order
//it will then give the amount of games in the array with an integer
import java.util.*;
public class MultipleClassesMain {
public static void main(String[] args) {
//Array holds 4 string inputs from user
String gameArray[] = new String[4];
//importing scanner element-------
Scanner input = new Scanner(System.in);
//Introduction---------------
System.out.println("Hey there!!!");
System.out.println("Please tell us four game titles you like to play!!!");
//Asks what game user likes and takes user input into a variable
System.out.println("So what a game you like?: ");
String temp = input.nextLine();
//This loop will test against blank user input
while (temp.equals("") || (temp.equals(" ")){
System.out.println("Your game can't be blank. Enter again: ");
}
}
}
This is the code I have so far. If anyone could give me some constructive criticisms and some pointers on how to loop through user input(testing for input) and appending the inputs to the array, I'd greatly appreciate it.
Cheers