这是我的代码片段:
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的下一个整数,并在nextPlayer的下一行读取,但它完全跳过firstPlayer,不允许我为它输入。为什么是这样?在此先感谢:)
谢谢!