12

I am new to Java ... is there a similar method to the ReadKey() in C# to avoid that a console application closes?

thanks

4

2 回答 2

17

您也可以使用System.in.read(),如果您可以将“Enter”键作为您的退出键。

于 2013-02-17T04:06:34.780 回答
10

一种方法:

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
br.readLine();

肯定有更短的,但我认为这个很方便,因为它可以很容易地扩展。

于 2010-03-28T18:35:05.937 回答