抛异常时的一些异常~~~
public class ExceptionTest {
public static Integer i = 0;
public static void main(String[] args) throws Exception{
try{
if(i != 0)
throw new Exception("sadlfj");
}catch(NullPointerException e){
System.out.println("Caught NullPointerException111");
}finally{
System.out.println("Got through new");
}
try{
i = 10;
System.out.println(i.toString());
}catch(NullPointerException e){
System.err.println("Caught NullPointerException222");
}finally{
System.out.println("Got through it");
}
}
}
输出结果:
Got through new
10
Got through it
我觉得如果没有在第一个try块中没有抓住异常,就不应在执行第二个try块啊,但是为什么第二个try块也执行了???和finalize有关系么?
public static Integer i = 0;
public static void main(String[] args) throws Exception{
try{
if(i != 0)
throw new Exception("sadlfj");
}catch(NullPointerException e){
System.out.println("Caught NullPointerException111");
}finally{
System.out.println("Got through new");
}
try{
i = 10;
System.out.println(i.toString());
}catch(NullPointerException e){
System.err.println("Caught NullPointerException222");
}finally{
System.out.println("Got through it");
}
}
}
输出结果:
Got through new
10
Got through it
我觉得如果没有在第一个try块中没有抓住异常,就不应在执行第二个try块啊,但是为什么第二个try块也执行了???和finalize有关系么?
...全文
相关推荐
虚拟抛硬币程序.rar
**循环结构**:为了实现连续多次的抛硬币,可以使用`Do...Loop`或`For...Next`等循环结构。用户可以选择指定投掷次数,或者在点击按钮时自动进行一定次数的投掷。7.
运行时异常与一般异常的区别?
如:NullPointerException 为最常见的异常之一。出现运行时异常后,系统会把异常一直往上层抛,一直遇到处理代码。
Python 解决中文写入Excel时抛异常的问题
然而,当你尝试用Python将包含中文字符的数据写入Excel时,可能会遇到一些编码问题,导致程序抛出异常。本文将详细介绍如何解决Python在写入Excel时遇到的中文字符编码异常。
Android跨进程抛异常的原理的实现
需要注意的是,虽然Android本身不支持直接跨进程抛异常,但开发者可以通过设计合理的通信机制来模拟异常处理,确保服务端的异常能够在客户端得到妥善处理。
Java中内存抛异常情况
Java中内存抛异常情况


Java SE
