0

これは私のコードのスニペットです:

public static void main(String[] args) {
    System.out.println("This is the square root game. Only two players allowed.");

    Scanner scan = new Scanner(System.in);
    System.out.println("How many rounds are you two playing?");
    int numofRounds = scan.nextInt();

    System.out.println("First player, what is your name?");
    String firstPlayer = scan.nextLine();
    System.out.println();

    System.out.println("Second player, what is your name?");
    String secondPlayer = scan.nextLine();
    System.out.println();

すべて問題ありません。numofRounds の次の整数を読み取り、secondPlayer の次の行を読み取りますが、firstPlayer を完全にスキップし、入力を許可しません。どうしてこれなの?前もって感謝します :)

了解、ありがとう!

4

0 に答える 0