Nehmen Benutzereingaben und hinzufügen zu einem array

So, ich bin umlernen, java und es ist schon eine Weile her. Ich versuche zu bauen, ein basic-Programm (siehe code-Kommentare) und ich habe Probleme erinnern, wie Sie Benutzereingaben erfolgen, und fügen Sie es in ein array. Ich habe mehr Mühe, sich zu erinnern, wie, um eine Schleife durch die Eingaben des Benutzers und testen, ob Sie Eingang alles sowie ist, indem der input in das array, wenn Sie die Eingabe etwas.

//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: ");

        }

    }

}

Dies ist der code, den ich bisher haben. Wenn jemand könnte mir ein paar Konstruktive Kritiken und einige Hinweise, wie man eine Schleife durch Benutzer-Eingabe(Test für input) und Anhängen der Eingänge auf die Reihe, ich würde es sehr zu schätzen.

Cheers

InformationsquelleAutor hijaked79 | 2012-12-23
Schreibe einen Kommentar