gpt4 book ai didi

Java 控制台在继续之前提示输入 ENTER

转载 作者:搜寻专家 更新时间:2023-10-30 19:52:39 25 4
gpt4 key购买 nike

<分区>

我正在创建一个简单的故事,偶尔会提示用户按 ENTER。它在我第一次提示它时工作,但随后它会立即执行其他提示,可能是因为当您按下 ENTER 键时程序运行得非常快,它已经运行了提示检查。

有什么想法吗?代码如下。

    System.out.println("...*You wake up*...");
System.out.println("You are in class... you must have fallen asleep.");
System.out.println("But where is everybody?\n");
promptEnterKey();

System.out.println("You look around and see writing on the chalkboard that says CBT 162");
promptEnterKey();

//////////////////////////////////////////////////////

public void promptEnterKey(){
System.out.println("Press \"ENTER\" to continue...");
try {
System.in.read();
} catch (IOException e) {
e.printStackTrace();
}
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com