Dark Horse programmer-java Base-exception

Source: Internet
Author: User

Exception Description Program exceptions: Throwable serious problem: Error we do not handle.           This kind of problem is usually very serious, for example memory overflow.        Issue: Exception compile-time problem: The exception that is not runtimeexception must be handled, because you do not process, the compilation cannot pass. Run-time issue: runtimeexception This problem we also do not deal with, because it is your problem, and this problem appears certainly is our code is not rigorous, need to fix the code. The code structure of the exception

Try {

Code that may be problematic;

}catch (Exception name variable) {
deal with the problem;
}finally {
releasing resources;
}

After the problem is found in the try, the JVM will help us generate an exception object and then throw the object and match the class in the catch.   If the object is of a certain type, the processing information inside the catch is executed.           Several methods to understand in the Exception class: public string GetMessage (): Exception message string public string toString (): A simple information description that returns an exception that contains the following information: The name of the class of this object (full pathname) ":" (a colon and a space) invokes the result of this object Getlocalizedmessage () method (the contents of GetMessage () are returned by default) Prin Tstacktrace () Gets the exception class name and exception information, and where the exception appears in the program. return value void. Output information to the console. The problem of finally statement block: Finally: The body of the statement that is finally controlled must be executed. Note: If the JVM exits before executing to finally, it cannot be executed. For example, there are system.exit (0) in catch;

Note: Return does not return the function immediately, but the return statement executes, and the returned result is placed in the function stack, where the function does not return immediately, and it does not actually begin to return until the finally statement is executed.

Dark Horse programmer-java Base-exception

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.