Is there any functionality in Java for pausing the program like system("PAUSE");
does in C++?
The Short Is Yes, But You Have To Build It Using The Standard Output With System.out
and Using The Scanner
Class To Wait For New Line Input ('\n') From Standard Input From The System.in
public class PauseTest {
public static void main(String args[]){
System.out.println("Press Any Key To Continue...");
new java.util.Scanner(System.in).nextLine();
}
}
NOTE: I used a direct reference to the Scanner
Class in java.util
package, but you could simply add the import java.util.Scanner;
or import java.util.*;
Basically the same thing.
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