所以我正在编写一些模拟三角纸牌游戏的代码。教授希望以以下格式立即输入董事会布局:
P
PP
OPP
POPP
PPPPP
PPPPPP
需要放入6x6阵列
然而,当我使用这个代码时:
Scanner consoleInput = new Scanner(System.in);
System.out.println("INPUT INSTRUCTIONS: Please input board data via copy/paste.");
System.out.println("Any invalid character (not 'o' or 'p') will be change to 'o' automagically.");
String input = consoleInput.next();
while (consoleInput.hasNextLine()) {
String line = consoleInput.nextLine();
System.out.println(line);
}
consoleInput.close();
一切都打印得很好,但第一行被跳过了。在花了两个小时之后,我头上的头发掉了大约50%。。。
谢谢!
String input = consoleInput.next();
是您的第一行。