Attention:
All exceptions in 1.Java are objects generated by subclasses of the Throwable class, and all exception classes are subclasses of subclasses or subclasses of the Throwable class. The Throwable class is a direct subclass of the object class, and the error class and the exception class are the two direct subclasses of the Throwable class.
Error class
Java.lang.Error
The error class typically refers to a virtual machine-related
Exception Exception class
The 2.java.lang.exception class is the direct or indirect parent class for all exceptions in Java
Exception handling in Java is implemented by 5 keywords Try,catch,finally,throw,throws
The difference between throw and throws:
Throw is a statement that throws an exception, and throws is a declaration that an exception can occur
Exception capture Syntax:
Try { // put code that could be faulted here catch (Exception e) { // If an exception occurs in the try block then it is caught by the catch } finally { // Whether or not an exception occurs finally executes // if System.exit appears in a try or catch ( 0) Finally block will not execute because the Java Virtual machine has been closed }
Multi-Path Exception capture syntax:
//Multi-path anomaly capture Try { //put code that might be wrong here}Catch(NullPointerException e) {//Multi-Path exception capturing subclass exception in front}Catch(Exception e) {//Parent class exception in the back}finally{ //Whether or not an exception occurs, the finally will execute//if the System.exit (0) Finally block appears in a try or catch, it will not execute because the Java virtual machine has been shut down}
Multi-Path Exception capture Note: The subclass exception is before the parent class exception
Configure log4j Picture Tutorial (no tutorial):
==========================================================================
The following is a exception directly known subclass Aclnotfoundexception, Activationexception, alreadyboundexception
ApplicationException, Awtexception, backingstoreexception
Badattributevalueexpexception, Badbinaryopvalueexpexception, badlocationexception
Badstringoperationexception, Brokenbarrierexception, Certificateexception, classnotfoundexception
Clonenotsupportedexception, Dataformatexception, Datatypeconfigurationexception, DestroyFailedException
Executionexception, Expandvetoexception, Fontformatexception, Generalsecurityexception, GSSException
Illegalaccessexception, Illegalclassformatexception, Instantiationexception, Interruptedexception, Introspectionexception
Invalidapplicationexception, Invalidmididataexception, Invalidpreferencesformatexception, Invalidtargetobjecttypeexception
InvocationTargetException, IOException, Jmexception, Lastownerexception, Lineunavailableexception, Midiunavailableexception
Mimetypeparseexception, Namingexception, Noninvertibletransformexception, Nosuchfieldexception, Nosuchmethodexception
Notboundexception, Notownerexception, ParseException, Parserconfigurationexception, PrinterException, Printexception
Privilegedactionexception, Propertyvetoexception, Refreshfailedexception, Remarshalexception, RuntimeException, Saxexception
Servernotactiveexception, SQLException, TimeoutException, Toomanylistenersexception, Transformerexception, Unmodifiableclassexception
Unsupportedaudiofileexception, Unsupportedcallbackexception, Unsupportedflavorexception, Unsupportedlookandfeelexception
URISyntaxException, Userexception, Xaexception, Xmlparseexception, XPathException
==================================================================================================
Java exceptions, configuring log4j