<a href= "http://www.goodprogrammer.org/" target= "blank" >android training </a>------My Java notes and look forward to communicating with you!
1. Exception: The program is running in the event of an abnormal situation.
Exception Origin: The problem is also a specific thing in real life, can also be described in the form of Java classes. and encapsulated into objects. In fact, Java is a description of the abnormal situation after the object.
The problem is divided into two kinds: one is a serious problem, a non-serious one.
A) for serious, Java is described by the error class. For error, it is generally not written in a targeted code to handle it.
b) For non-critical, Java is described by the exception class. For exception, you can use a targeted processing method for processing.
Both error and exception have some common content. For example: abnormal information, causes of the cause and so on.
Throwable
|--error
|--exception
2. Exception handling: Java provides unique statements for processing.
try {
Code that needs to be detected;
}
catch (Exception class variable) {
Code to handle exception (processing mode)
}
finally {
Statements that are bound to be executed;
}
3. Handling of multiple exceptions:
1), when declaring an exception, it is recommended to declare a more specific exception. This can be handled more concretely.
2) The other side declares several exceptions, corresponding to a few catch blocks. Do not define an extra catch block. If an inheritance relationship occurs in multiple catch blocks, the parent exception catch block is placed at the bottom.
4. When you set up catch processing, you must define a specific processing method in the catch. Don't simply define a e.printstacktrace (), or simply write an output statement.
The difference between 5.throws and throw:
1) throws is used on the function. Throw is used within a function.
2) The exception class followed by the throws. Can be followed by multiple. separated by commas. The throw is followed by an exception object.
Java Learning Anomaly < good programmer training camp >