它在IF语句中工作,但在ELSE语句中,我必须在打印输出之前输入4个响应。有任何想法吗?我知道我需要以某种方式清除缓冲区,我想。如何清除缓冲区,以便工作?
System.out.println("Would you like to play a game? (Y/N)");
if(scanInput.next().equalsIgnoreCase("y")||scanInput.next().equalsIgnoreCase("Y")) {
System.out.println("let's play");
}
else if (scanInput.next().equalsIgnoreCase("n") || scanInput.next().equalsIgnoreCase("N")){
System.out.println("Goodbye");
}