Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我想在println和keypress之间等待_Java_Keylistener - Fatal编程技术网

Java 我想在println和keypress之间等待

Java 我想在println和keypress之间等待,java,keylistener,Java,Keylistener,我有一个程序,里面有正在打印的文本。我想知道如何才能使文本等待打印,直到我按enter键。 提前感谢。在程序顶部,创建一个带有系统的扫描仪。在中作为其来源: Scanner scan = new Scanner(System.in); 每当您想暂停时: System.out.println("Press ENTER to continue..."); // optional scan.nextLine(); 请详细说明这是最简单的方法,但并非在所有情况下都有效。

我有一个程序,里面有正在打印的文本。我想知道如何才能使文本等待打印,直到我按enter键。
提前感谢。

在程序顶部,创建一个带有
系统的
扫描仪。在
中作为其来源:

Scanner scan = new Scanner(System.in);
每当您想暂停时:

System.out.println("Press ENTER to continue..."); // optional
scan.nextLine();

请详细说明这是最简单的方法,但并非在所有情况下都有效。