Exception: An event that interrupts the normal instruction flow and is the object generated by the JVM virtual machine
exceptions are generated when the program is run , and are not related to compilation
Class test{public static void Main (String args[]) { System.out.println (111111); int i = 1/0; System.out.println (222222); }}
The above is an arithmetic exception (a subclass of Runtimeexcepiotn), and when an exception occurs, the statement following the exception is no longer executed.
Classification of exceptions: classes provided by the JDK
All exception classes are subclasses of Throwable. Throwable two direct sub-classes are exception and error. Error refers to the JVM's errors, and once an error occurs, the JVM shuts down and the program ceases to exist, and the programmer is powerless to error. Exception can also be divided into uncheckexception and checkexception. Uncheckexception includes subclasses of Runtimeexcepiotn and Runtimeexcepiotn. The immediate subclasses of exception belong to Checkexception except for Runtimeexcepiton.
The difference between uncheckexception and checkexception:
When a program is likely to appear checkexception, the compiler will force you to handle and capture code that might appear to be an exception.
Handling Exceptions using try...catch...finally snapping
Class Test{public static void Main (String args[]) {System.out.println (111111); try{system.out.println (222222); int i = 1/ 0; System.out.println (333333);} catch (Exception e) {e.printstacktrace (); System.out.println (444444);} Finally{system.out.println (555555);} System.out.println (666666);}}
When the program is running an exception is transferred to the catch to execute, if there is no exception to execute the code in the catch, and finally the code regardless of whether an exception will be executed.
Exceptions in Java