On Java anomaly mechanism
Work idle come to nothing, look at the basics of Java, do a summary
Exception mechanism: A solution to a control process that is provided by Java to resolve an unexpected or misoperation operation
Throwable all errors or exceptions, containing two subclasses of error and Exection
Where error errors are not handled by the program, such as memory overflow, machine power off, etc.
Exception exceptions include run-time exceptions and compile-time exceptions
Run-time exception classes are inherited runtimeexception, common such as nullpointerexception,arithmeticexception,indexoutofboundsexception, etc.
Compile-time exceptions, non-runtime exceptions, must be processed when compiling, such as IOException (subclasses such as FileNotFoundException)
Exception handling:
1) try{
Action to be performed by the program
}catch (Arthmeticexception e) {
Actions that the program may perform
E.printstacktrace ();
}catch (Exception e) {
Actions that the program may perform
}finally{
The action that the program is bound to perform
}
Tip: You can learn more about the process of Try catch by return
Note: Exception class scope size problem in multi-layer catch
2) throws and throw
Throws is declaring an exception
Throw throws a real exception to the object
Note: An exception is thrown where the exception is declared, and if the caller does not process it, the exception will continue to be thrown up
Custom Exceptions:
You can customize your own exception class as needed, and define the exception class that inherits exception normally.
Cond....
Java exception mechanism