1. Study summary 1.1 This week summarize anomalies in the way you like (mind mapping or other).
2. Written work this time PTA work problem set abnormal 1. Common exception Combination Topic 7-1 Answer 1.1 What anomalies do you often have in your previously written code and need to be captured (why)? What should be avoided?
A: There have been NullPointerException , neither ClassCastException of these exceptions need to be captured, because they are inherited from RuntimeExceotion . To avoid this, we should be careful to judge null pointers, coercion type conversions, while writing programs.
1.2 What kind of exception requires the user to be sure to use capture processing?
A: Except Error RuntimeException for exceptions that are outside the exception class and its subclasses, users are required to use capture processing.
2. Handling exceptions to make your program more robust The topic 7-22.1 experiment Summary. And answer: How can you make your program more robust?
A: In the For loop Try-catch catch exception, you need to be aware of the catch block in the output of an exception after the "i--", otherwise there will be an error.
To make the program more robust, you will learn to capture and handle various exceptions.
- Throw and throws
Topic 7-3 Reading Integer.parsetint source Code 3.1 Integer.parsetint There is a lot of code to throw the exception at the beginning, what is the benefit of this practice?
A: The advantage is that you let us know where the exception occurred, so that we can resolve the code that handles the exception.
3.2 What information do you usually need to pass to the caller when you write your own program with 3.1 and analyze your own method of throwing an exception?
A: The message needs to be passed to the call: when the passed-in character is null and Radix<character.min_radix, an exception is thrown NumberFormatExceotion .
4. Use exceptions to improve Arrayintegerstack title 6-34.1 combined with 6-3 code, answer the question of how to use throw exception to represent the program run error what is the benefit? What is the advantage of returning an error value more than a simple one?
A: Be able to locate more accurately, find the wrong location, make the program more robust. If you are simply returning an error value, you will first need to take the time to find the location where the error occurred before further processing can occur.
4.2 If the inner code of a method throws an exception of type RuntimeException, does the method declaration use the throws keyword, and if the exception that is thrown by the method is declared using the throws keyword, what benefit can it bring us?
Answer: You should use throw keywords. Benefit: Make your code more robust.
5. Function questions-Multiple exception capture topic 6-15.1 combined with 6-1 code, answer: If you can throw multiple exceptions in a try block, and there may be an inheritance relationship between exceptions, what do you need to be aware of when capturing?
A: You need to be aware of the inheritance relationship between multiple exceptions, that is, you should first snap the subclass and then capture its parent class.
5.2 If you can throw multiple exceptions in a try block, what do you need to be aware of when using Java8 's multiple exception capture syntax? 6. Add exception handling to the following code
6.1 Correct the code and add the following functions. When the file cannot be found, you need to prompt the user not to find the file xxx, retype the file name, and then try to open it again. If it is another exception, prompt to open or read the file failed!. Feature 2: You need to add a finally close file. Regardless of whether the above code produces an exception, always be prompted to close the file ing. If closing the file fails, prompting to close the file failed!6.2 combined with the 6-2 code, what kind of action to put in the finally block? Why? What do I need to be aware of when closing resources using finally? 6.3 Use try-with-resources in Java7 to rewrite the above code to automatically close the resource. What are the benefits of this approach? 7. Object-oriented design job-Library management system (group complete, no more than 3 students per group) login lib.jmu.edu.cn, search for books. Then log in to the library information system to view my library. If you want to implement a book borrowing system, try using object-oriented modeling. 7.1 Who is the user of this system? 7.2 Main function modules (not too many) and the owner of each module. Next week everyone is going to submit their own module code and run the video. 7.3 Main class design and class diagram of the system (available) 7.4 How you plan to store library information, address information, reader information, and more. 3. Code Cloud and PTA Topic set: Exception 3.1. Code cloud codes submitted in the Code cloud Project, select "Statistics-commits history-set the time period", and then search and 3.2 PTA Folio completion diagram needs to have two pictures (1. Ranking chart. 2.PTA Submission List Chart) 3.3 The amount of code that is completed this week requires that the weekly code statistics be fused into a single table.
JAVA Week-----exception