package Exception;
public class Finally {
public static void main(String[] args) {
// TODO Auto-generated method stub
Finally tct=new Finally();
int result=tct.test();
System.out.println("test()方法,执行完毕!返回值为:"+result);
int result2=tct.test2();
System.out.println("我想大声告诉你!test2()2执行完毕!!~");
}
public int test() {
int divider=10;
int result=100;
try {
while(divider>-1) {
divider--;
result=result+100/divider;
}
return result;
}catch(Exception e) {
e.printStackTrace();
System.out.println("circulation throw exception!!!");
return -1;
}
}
public int test2() {
int divider=10;
int result=100;
try {
while(divider>-1) {
divider--;
result=result+100/divider;
}
return result;
}catch(Exception e) {
e.printStackTrace();
System.out.println("circulation throw exception!!!");
return result=999;
}finally {
System.out.println("这是finally!!哈哈!!");
System.out.println("这是Result!!我的值是:"+result);
}
}
}
慕容7724642
木偶匹诺曹
相关分类