Java Basics Supplements (ii)

Source: Internet
Author: User

1.finally

 Public Static int func () {        try{            return 1;        } Catch (Exception e) {            return 2;        } finally {            return 3;        }    }
 Public Static int func () {        try{            thrownew  Exception ();        } Catch (Exception e) {            return 2;        } finally {            return 3;        }    }

The return value is 3, which indicates that the code of the finally block is executed before the normal return;

Relationships between 2.java exception-handling classes

Exception inheritance structure: The base class inherits Throwable,runtimeexception and IOException inheritance from Throwable,error and Exception Exception

Non-runtimeexception is generally an external error, which must be captured by the Try{}catch statement block

The error class system describes internal errors and resource exhaustion scenarios in the Java operating system, and error does not require capturing

3. Thread run () method

Thread classes want to open a new thread the start () method must be executed, and the run () method implemented by the class is called inside the start () method. If you execute run (), it is equivalent to executing a normal method that belongs to the current thread.

Java Basics Supplements (ii)

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.