"Java Programming" (9)

Source: Internet
Author: User

This week we learned about anomalies, assertions. When we are not in touch with this chapter, we will be in the process of running the program also some errors, sometimes prompted, use the time without prompting. So an exception is created, and if the program appears in error, an exception is thrown, which interrupts the program. Exceptions are classified into fatal and non-fatal exceptions. All exceptions are throwable inherited, and the next layer is divided into error and exception. Throw an exception with the throw new ... can also be written in the method header, with throws. Creating an exception requires only that you define a class that derives the exception or that derives from the exception subclass. The catch exception must use the try{},catch{} statement, either to catch an exception or to catch multiple exceptions.

The assertion is for the debugger to be able to quickly and easily check for program exceptions, but Java is not enabled by default, so open the assert "switch" in the settings,-ea. Assertions are primarily used during code development and testing, to judge certain critical data, and if the key data is not the data your program expects, the program warns or exits. By doing experimental work can feel the anomalies and assertions in the code of the existence of the program, if you need to master or more practice. As opposed to the previous content, it seems that there is no particular abstraction that can be understood.

"Java Programming" (9)

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.