javaconsoleconsole.readkey

Readkey in Java


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

thanks


Solution

  • One way to do it:

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

    there are definitely shorter ones, but I think this one's convenient, because it can easily be extended.