201671010115 Java experience in Java programming Nineth week of 2016-2017-2

Source: Internet
Author: User
Tags assert

This week, we learned the seventh chapter of Java-Exceptions, assertions, and logs-as I know from the knowledge of this chapter:

Exception, which is the exception event that occurs during the execution of the program, interrupts the normal execution of the instruction. It is inherited by Throwable , mainly including the error and the exception two parts, Then exception this level includes RuntimeException (unchecked exception) and IOException (checked for exceptions). All exceptions to the error class and the RuntimeException class are known as non-checked exceptions, and all other exceptions are referred to as checked exceptions. So my understanding is that the exception is not checked when the program is running, the error will be displayed, the system will prompt the error, and then need the compiler to modify the code on the corresponding number of lines, but check the exception requires the compiler to declare the exception or catch exception of the two types of exception processing technology, if not processed, the program does not need to run will be directly error.

assertions, which are tools for inserting some code error detection statements in the development and testing phases of a program. The assertion (Assert) syntax is as follows:

1. Assert condition or 2, assert condition: expression

Both forms will judge the Boolean "condition", if the result is False (false), the program is already in an incorrect state, the system throws Assertionerror, gives a warning and exits. In the second form, the expression is passed into the Assertionerror constructor and is converted to a message string.

When to use assertions to remember two points: 1) Assertion failure is a fatal, unrecoverable error. 2) assertion checking is only used in the program development and testing phase.

Assertions are used to locate program internal errors only during the test phase.

For this experiment content, there are great problems in the log, a lot of code is not very understanding, and then, is the exception class in the creation of problems, their own in dealing with the exception class problem is a bit unclear how to deal with, and the breakpoint is set up, the program has no change, is not quite understand.

201671010115 Java experience in Java programming Nineth week of 2016-2017-2

Related Article

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.