Santhiya Park Java SE Training Summary (69-) (Annotation, exception handling)

Source: Internet
Author: User
Tags throw exception try catch

    1. If a annotation defines a property and the name is value, then there are two ways to assign a value to it when using this annotation, one is ("value") one is (value=value value), if the property name is not value, Then you can only use the second method!
    2. JUnit Framework 3.0, the class to be tested needs to inherit the TestCase class, and the method that needs to be tested needs to start with the name of test! 4.0, directly using @test written on the method above, you can test!
    3. Exceptions in Java can be divided into two classes of checked exception (non-runtime exception), the second unchecked exception (runtime exception), As long as the exception that inherits RuntimeException is a run-time exception, the class that inherits exception does not inherit Runtimeexceptio is called a non-runtime exception! Note that RuntimeException also inherits Exception, but Exception is a non-runtime exception
    4. If a method throws a non-runtime exception, such as throw Exception (), for a non-runtime exception that must be handled at the time of writing the program, there are two ways to handle it, and one is to catch the exception at a try catch at the method call. The second is to throw out the method declaration of this method, for example, with throws Exception, if the compiler does not handle the error
    5. For run-time exceptions, such as a divisor of zero, this exception does not need to be handled, and the recommended practice is not handled!
    6. The execution process for a try Catch finally is: An exception is produced in a sentence in a 1,try statement block, after which the statement in the statement block is not executed, and if the resulting exception matches the exception in the catch parenthesis, then the statement in the block of the catch statement is executed! 2, if no exception is generated, the statement in the TRY statement block is executed and the statement in the CATCH statement block is not executed.
    7. Regardless of whether an exception occurs, the statements in the finally statement block are executed. A statement that contains a large statement block of Try catch, even if the statement behind those try catch blocks executes
    8. Null pointer exception occurs because a reference to a null, and you also use this reference to call a method, you will definitely report NULL pointer exception!

San Think garden Java SE Training Summary (69-) (Annotation, exception handling)

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.