这是我的代码片段:
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 并且不允许我输入它。为什么是这样?提前致谢 :)
知道了谢谢!