Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I am new to Java ... is there a similar method to the ReadKey() in C# to avoid that a console application closes?
thanks
您也可以使用System.in.read(),如果您可以将“Enter”键作为您的退出键。
System.in.read()
一种方法:
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br.readLine();
肯定有更短的,但我认为这个很方便,因为它可以很容易地扩展。