异常Exception(发生在运行时):运行时异常(人为的)(概率小)(NullPointerException)------------------------------------->RuntimeException
编译时异常(外部条件决定的)(概率大)(FileNotFoundException)----->Exception
异常的处理:1.上抛(最迟在main中处理)(throws)
2.现场处理(try......catch)(try......finally)
public class ExceptionTest11 {
public static void main(String[] args) {
try {
System.out.println("try...");
return;
} finally {
System.out.println("finally...");
}
}
}
try {
} catch (ClassNotFoundException e) {
e.printStackTrace();
}