首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

JAVA Exception错误总结(JAVA Exception面试笔试总结)

2012-12-25 
JAVA Exception异常总结(JAVA Exception面试笔试总结)这方面主要有以下几种类型的题目:1 try中throw一个ex

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后面的代码还是继续执行的。



热点排行