try...catch出现Unreachable code ?
是照着老师写的抄的,也没查到是什么原因
是照着老师写的抄的,也没查到是什么原因
2015-01-14
老师的代码是:
package com.imooc.test;
public class TryCatchTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
TryCatchTest tct=new TryCatchTest();
int result = tct.test();
System.out.println("test方法执行完毕,返回值为:"+result);
}
public int test(){
int divider = 10;
int result=100;
return 0;
try{
while(divider>-1){
divider--;
result=result+100/divider;
}
return result;
}catch(Exception e){
e.printStackTrace();
System.out.println("抛出异常了 ");
return -1;
}
}
}
举报