Read "Java programming ideas" concluded ------ Chapter XII (exception handling error)

The basic philosophy of Java is "poor structure of the code is not run."

You never have to clean up before an exception object to worry about, or to clean the exception object to worry about. Because they are in the use of new objects created on the heap, the garbage collection mechanism will automatically put them clean out.

Throwable objects can be divided into two types (type refers to inherited from Throwable obtained): Error is used to compile-time and system errors (except in special circumstances, you generally do not care about); Exception is the basic type can be thrown in Java class libraries, methods, and user runtime failure could throw an Exception exception.

Remember: only a RuntimeException ignored (and its subclasses) types of exceptions in the code, other types of exception processing is enforced by the compiler.

When thrown, the exception handling system will find the "nearest" handlers in the writing order code. After finding the matching processing program, it is believed an exception would be addressed, then do not continue to look for.

Exception handling is an important principle is "only catch exceptions in you know how to handle the situation." In fact, an important goal is to exception handling code in the same location error handling error occurs phase separation.

Guess you like

Origin blog.csdn.net/keyto1/article/details/92384232