读书人

JAVA Exception错误总结(JAVA Except

发布时间: 2012-12-25 16:18:29 作者: rapoo

JAVA Exception异常总结(JAVA Exception面试笔试总结)

这方面主要有以下几种类型的题目:

1 try中throw一个exception,能否直接catch?

/** * try中代码执行哪些?try catch 后面代码是否执行?输出什么 */public void method5(){try{System.out.println("method step1");new String("abc").subSequence(0, 5);System.out.println("method step2");}catch(StringIndexOutOfBoundsException e){System.out.println(e.getMessage());}catch(Exception e){System.out.println(e.getMessage());}System.out.println("method step3");}
解答:这个里里面,try中抛出异常后,try里下面的代码就不执行了,直接进入了catch,如果try中抛出的异常被catch到了,那么catch后面的代码还是继续执行的。



读书人网 >编程

热点推荐