"DAY7" on the seventh day of abnormal learning notes

Source: Internet
Author: User

Abnormal

-------------------

Two subcategories of 1.throwable exception and Error.

2. Use the throw key to throw an exception object.

throw new Xxxxexception (...);

3. Method definitions can be added when throwing exception declarations

public void Mname (...) throws Xxxxexception,.... {...}

4.RuntimeException can not throw a declaration when the method is defined.

5.RuntimeException throws can be captured without the use of try-catch-finally.

6. Exception is not catch processing, will be thrown further.

7. When the method overrides, you cannot append a new exception to the throw declaration, but you can throw a subclass of the exception that is declared by the overridden method.

on the difference between throws and throw

Throws is used to denote an exception that is exposed by a function.

Throw is used to throw the exception object throw new Xxexception (..)

Throws used on functions, followed by the exception class name

Throw is used inside a function, followed by an object with an exception

exception Handling:

try{//method to be detected, object code.

}

catch (Exception e) {//How to handle these exceptions.

}

finally{//code that is bound to execute after the exception is processed (with or without exceptions).

}

Example:

To use on a method function: throws Exception

Inside the method: Throw object New Xxexcepton ()

Write to try in Call: Try{}catch () {}finally{}

member access rules


Public Protected Default Private
In the same
In the same package
Sub-class

Different packages



Package

--------------------

packages, folders.

Java/lang/xxxx

Jar:java Archieve,java archive file.

Java/lang/object.class

Full name, complete class name: Java.lang.Object java/lang/object

Specify the class file directory at compile time using the- d parameter: java-d xx/xxx Packagedemo.java

The runtime specifies the directory where the class file is locatedusing the-CP parameter: JAVA-CP xx/xx A


This article is from the "Yehomlab" blog, make sure to keep this source http://yehom.blog.51cto.com/5159116/1784238

"DAY7" on the seventh day of abnormal learning notes

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.