2015-12-31
A . Exception handling
Exception Overview (exception/error)
Exception handling mechanism
Catching exceptions using try{}catch ()
Inheritance system for exception classes ( Small exceptions are handled first , and large exceptions are handled )
Multiple exception captures provided by Java7
Access exception information
Use finally to reclaim resources ( explicitly reclaim physical resources garbage-collected heap memory return System.exit (1))
Nesting of exception handling
-
java7 Auto-close resource try statement with parentheses )
-
checked exception and runtime exception system
-
throws declaration throws exception ( method signature )
Throw an exception with throw
Throw exception ( business logic decision )
-
custom exception class ( no parameter constructor single parameter string Constructor single parameter throwable constructors super)
catch and throw are used simultaneously ( layered )
Java7 Enhanced throw statement
Exception chain ( exception translation responsibility chain pattern encapsulates the original exception )
Java exception-tracking stack
Exception handling mechanism
Do not over-use exceptions ( efficiency )
Do not use an overly large try block
Avoid using catch all statements
Do not ignore the caught exception
Java reading notes (1)-Exception handling