Java Program to Use exit() Function

The java.lang.System.exit() method exits current program by terminating running Java virtual machine. This method takes a status code. A non-zero value of status code is generally used to indicate abnormal termination.

exit(0) – Generally used to indicate successful termination.exit(1) or exit(-1) or any other non-zero value – Generally indicates unsuccessful termination.