Java Basic Note 11

Source: Internet
Author: User

Abnormal:

The exception that occurs when a Java program is Running.
How Java handles Exceptions.
try{
Where the anomaly may have occurred
}catch (exception type Object) {
Exception Handling Office
}catch (exception type Object) {

}......finally{
Whether or not an exception will be Executed. Close the Resource.
}
The exception type range for the following catch must not be less than the range of the above catch exception type.

Common exceptions, and how to exclude some common exceptions.
  arithmeticexception: Arithmetic exception example: operation encountered 10/0 is
  numberformatexception: Format Conversion Exception example: when a string type is converted to a numeric type
  arrayindexoutofboundexception: Array subscript is out of bounds. Example: exceeding the array length
  nullpointerexception: null pointer exception. Example: Object. method (); at this point, if the object is a null, the runtime produces a null pointer Exception.
  classcastexception: class conversion Exception. Example: when a parent class object is transitioning Down.
The parent class of the exception class.
  Throwable:
    Exception: Exception class. Programmers can handle
    error : Wrong class. Memory Overflow. The programmer cannot handle it.

throws Keywords

Public return value type method name (argument List) throws Exception class name {}

Indicates that this method does not handle the exception and is processed at the call of the Method.

the throw keyword directly throws the resulting exception object.

Java Basic Note 11

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.