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