Introduction
If you need to exit from a running program, you can do it with the System.exit() command. The parameter of exit should qualify if the execution of the program went good or bad. It’s a sort of heredity from older programming languages where it’s useful to know if something went wrong and what went wrong.
// No errors int errorCode = 0; // An error occurred errorCode = -1; // Terminate System.exit(errorCode);