20155317 Wang Ying 2016-2017-2 "Java Programming" 5th Week study Summary

Source: Internet
Author: User
Tags throw exception throwable

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.
    1. A.erroe with its subclass instance represents a serious system error.
    2. 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.
    1. 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
  •  Public Test () throws repletexception {    try  {      System. out. println ("Test this project! " )    }    catch  (Exception e) {      thrownew  Exception (E.tostring ());    }  }
  • Question: What is the difference between throw and throws? Can I change this to a throw?
  • After searching the internet, I found:
  • Throws is used to declare all exception information that a method may throw, while throw refers to a specific exception type thrown. Usually in a method (class) declaration through throws declaration method (class) may throw exception information, and in the method (class) through the throw declaration of a specific exception information. Throws usually does not display the catch exception, and the system automatically throws all the caught exception information to the Ancestor method. The throw will require the user to catch the relevant exception, and then wrap it in the wrapper, and finally throw the exception after the package.

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 /Cumulative) new/cumulative)
lines of code (newBlog volume (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

    • Planned study time: xx hours

    • Actual study time: xx hours

    • Improved situation:

(Take a look at the software engineer's ability self-evaluation table of the modern soft-ware courseware)

Resources
    • Java Learning Notes (8th Edition)

    • Java Learning Note (8th Edition) Learning Guide

    • ...

20155317 Wang Ying 2016-2017-2 "Java Programming" 5th Week study Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.