I am new to Java ... is there a similar method to the ReadKey() in C# to avoid that a console application closes?
thanks
I am new to Java ... is there a similar method to the ReadKey() in C# to avoid that a console application closes?
thanks
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.
import java.io.BufferedReader;
(and import java.io.InputStreamReader;
). –
Ticknor enter
key pressed. ReadKey only wait and read for a single any character. –
Punchboard YOu can also use System.in.read()
, if you are ok with just 'Enter' key being your exit key.
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.
import java.io.BufferedReader;
(and import java.io.InputStreamReader;
). –
Ticknor enter
key pressed. ReadKey only wait and read for a single any character. –
Punchboard © 2022 - 2024 — McMap. All rights reserved.