今天小黄遇到了:
Scanner f = new Scanner(System.in);
f.nextInt();
f.nextLine();
f.nextLine();
上面这三行语句只能执行上下两句,中间一句的输入不见了,
后来才发现中间的nextLine()读取了nextInt()最后的Enter,导致它直接算输入完毕,
我觉得这是个bug.
最后也是想出了解决办法:
既然中间的nextLine()会读前面的Enter,那么我弄两个Scanner对象它就读不到了,嘿嘿嘿···
Scanner f = new Scanner(System.in);
Scanner w= new Scanner(System.in);
f.nextInt();
w.nextLine();
w.nextLine();
成功!!