抛异常时的一些异常~~~
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
非常简单的虚拟抛硬币程序,可统计出次数和百分率。 用vb编的~ 不仅没事可以拿来抛一抛,还可以研究并修改。
运行时异常与一般异常的区别?
运行时 异常 与一般 异常 的区别的详细说明..
Python 解决中文写入Excel时抛异常的问题
下面小编就为大家分享一篇Python 解决中文写入Excel时抛异常的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
Android跨进程抛异常的原理的实现
主要介绍了Android跨进程抛异常的原理的实现,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
Java中内存抛异常情况
Java中内存抛异常情况


Java SE
