A common exception introduction
1.1 Compile-time exceptions
1. An abnormal SQLException generated by operating the database
2. Abnormal IOException generated by operating files
3. FileNotFoundException
4. Class not found exception ClassNotFoundException
5. IllegalArguementException
1.2 Runtime exceptions
1. NullPointerException
2. ArithmeticException
3. Array index out of bounds exception ArrayIndexOutOfBoundsException
4. Type conversion exception ClassCastException
5. NumberFormatException
Two exceptions in project analysis and processing (eclipse version)
2.1 Compile-time exceptions
Compile-time exceptions, the development tools will handle them directly during the process of writing code, use try...catch(Excetion e){}finally{}, or use the keyword throw to throw. If an exception occurs, it can be precisely located through the exception message and processing
2.2 Runtime exceptions
Runtime exceptions generally occur during code execution, and triggering exceptions is conditional.
Three complex exception handling
The above exceptions are relatively simple to handle. Whether it is a compile-time exception or a runtime exception, as long as it is reported on the console, the exception handling system of the Java language is very good in terms of exception location and message prompts. According to the prompts, it can be quickly located. Give and solve problems.
In daily development, some BUGs are troublesome to deal with, that is, the console does not report errors, does not output results, or the output results do not match the facts. Such BUGs need to be handled with the help of some tools when debugging, such as eclipse development The DEBUG mode of the tool.
The following uses the DEBUG mode of eclipse to simulate the processing of a BUG
3.1 Normal operation
3.2 Abnormal operation
This is to run without error, but the result is wrong.
3.3 DEBUG processing using eclipse
3.3.1 The first step
Step 1: Add a breakpoint to the code and run the code in DEBUG mode
Breakpoint: Double-click the side to the left of the code line number, a breakpoint will be generated, and the breakpoint will be canceled after double-clicking. If a breakpoint is added, when running in DEBUG mode, the code will run to the breakpoint and block.
3.3.2 The second step
Enter the DEBUG window for DEBUG debugging
3.3.3 The third step
Click the single-step button to run the code step by step and monitor data changes
3.3.4 The fourth step
Compare the data and get the answer
Qianfeng Education Java Introduction Full Set of Video Tutorials (java core technology, suitable for java zero foundation, necessary for self-study of Java)