How do you keep the console from closing after the program is done in Java?
readLine()
waits until you press a key:
public static void main (String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
in.readLine();
}
The simplest way I've found:
Scanner scanner = new Scanner(System.in);
scanner.nextLine();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With