If you have try catch within the loop it gets executed completely inspite of exceptions. As this is an abrupt termination, the system generates a message and displays it. Following is the declaration for java.lang.System.exit () method: public static void exit (int . Also for some of the return code you can refer to the snote mentioned with the exit code: #Common exitcodes: 0 =Normal exit. Let's define an enum for direction: public enum Direction { EAST, WEST, SOUTH, NORTH; } The name of the enum value is constant. Catch: If any exception occurs in the try block, it will be thrown. When . In simple words, we can say that a User-Defined Exception or custom exception is creating your own exception class and throwing that exception using the 'throw' keyword. You go to the bathroom to shower only to discover that the pipes are frozen. If try/catch blocks have a return statement, even then the finally block executes! Java provides Java.lang.Exception class for handling the exceptions which inherit the properties and methods of Object and Throwable class. Exception Handling in Java | Java Exceptions - javatpoint 1. Code: for ( ; ; ) { .. } Use Timer Class. When an Exception occurs the normal flow of the program is disrupted and the program/Application terminates abnormally, which is not recommended, therefore, these exceptions are to be handled. HttpClient.SendAsync method exits without throwing exception It takes an exit code, which it passes on to the calling script or program. We can also create unchecked exception class in Java. Now we can search the direction by its name. Programs run by the standard java.exe, however, happily return zero no matter how abruptly they end, unless the program calls System.exit () with an exit value. An arithmetic exception in java is thrown when we try to divide a number by zero. How to ensure my Java program keeps running until no exceptions ... - Quora