20155317 Wang Ying 2016-2017-2 "Java Programming" 5th Week study SummarySummary of learning contents of textbookException Handling & Collection and map exception inheritance schemas
- The wrong object inherits the Java.lang.Throwable class, and Throwable has two subclasses Java.lang.Error with Java.lang.Exceptions.
- A.erroe with its subclass instance represents a serious system error.
- B.exception and its subclass instances are exception handling.
- You must explicitly use the Try,catch syntax for processing, or declare this method with throw to throw an exception, or the compilation will fail.
- Exception to be inspected: must handle exception, but not belong to RuntimeException.
- Non-inspected exception: The program does not force processing. RuntimeException is raised by the client and belongs to the client about the modified content, if must be processed, the recommendation is to render friendly information.
- Note: If the parent exception object is caught before the subclass exception object, the catch subclass exception object Chunk will never be executed. First, the child class is captured.
Try, catch syntax
- There are many errors in using the program, such as the following code, which attempts to use the try and catch syntax, discovers that the JVM will attempt to execute the program code in the try block, and if an error occurs, skips the type declared in the error occurrence point comparison catch bracket, if the type of the thrown error object is met. The try, catch syntax can catch exceptions in the try section:
- No try, catch syntax, when an exception occurs when the program will error.
- When using the try, catch syntax, when an exception occurs, the program can still run normally, just storing the error information in the exception.
- That is, the catch function extracts the exception information.
Throw & Throws
- When an exception is encountered in the design process of a method, an exception can be thrown with throws FileNotFoundException, which is handled by the client calling the method.
Collection and Map Architecture collection
- In the Java.util.List interface, the index order of each object is recorded, and the object is retrieved according to the index.
- In the Java.util.Set interface, the collection object is not duplicated and has the behavior of the collection.
- In the Java.util.Queue interface, when objects are collected in a queue, the collected objects are added to the end, and the objects are acquired from the front end.
- Java.util.Deque interface, the two ends of the queue are added, removed, and so on.
Map
- It is a container for storing data in the form of key-value pairs, mainly using hash map as its common implementation class. Lambada and generics
Lambada
- The main function of this expression is to simplify the writing of anonymous functions and reduce the burden on programmers.
Generic type
- When collecting objects using collection, because the form of the collected objects is unknown, the internal operation uses object to refer to the objects being collected, and the objects are returned as object types when they are retrieved.
- Therefore, if you want to operate on a class defined behavior, you must tell the compiler to let the object re-play that type. The generic syntax is added after JDK5. If the interface supports generics, it is also easier to operate, as long as there is a specified type when declaring the reference, then the object is created without having to write the type.
- Generics can also be defined only on methods, most commonly by defining generics on static methods.
Problems in teaching materials learning and the solving process
When learning 8.1.1, see try, catch catch error cases, the book only caught an error, if there are multiple errors how to capture?
Solution: When learning to 8.1.2, see the fragments in the book
Try {things ...} Catch (IOException | interruptedexception | classcastexception e) {E.printstacktrace ();}
Problems in code debugging and the resolution process
Code Hosting
Last week's summary of the wrong quiz
- Wrong question 1 and reason, understand the situation
- Wrong question 2 and reason, understand the situation
- ...
reviewed the classmates blog and code
- Study No. 1
- Study No. 2
- Study No. 3
- Study No. 4
- Study No. 5
- Study No. 6
Other (sentiment, thinking, etc., optional)
This week came into contact with new knowledge and new concepts that had not been touched. But everything is a basic skill, feel if the basic knowledge of the previous not thorough understanding, not to mention the back, it is more and more difficult, good learning!
Learning progress Bar
|
lines of code (new | /Cumulative)
Blog volume ( | new/cumulative)
Learning time (new/cumulative) |
Important growth |
Goal |
5000 rows |
30 Articles |
400 hours |
|
First week |
200/200 |
2/2 |
20/20 |
|
Second week |
300/500 |
2/4 |
18/38 |
|
Third week |
500/1000 |
3/7 |
22/60 |
|
Week Four |
300/1300 |
2/9 |
30/90 |
|
Week Five |
486/1300 |
2/9 |
30/90 |
Try to record "planned learning time" and "actual learning time" to see if you can improve your planning skills by the end of the semester. This work is very important and useful in learning. Time-consuming estimates of the formula: y=x+x/n, y=x-x/n, the number of training, X, Y is close.
Reference: Why is it so difficult to estimate software engineering applications, software engineering estimation methods
(Take a look at the software engineer's ability self-evaluation table of the modern soft-ware courseware)
Resources
20155317 Wang Ying 2016-2017-2 "Java Programming" 5th Week study Summary