只显示:方法执行了 -1,没有提示说“循环抛出异常”?

来源:1-3 Java中通过案例学习 try...catch...finally

qq_力克_0

2016-10-27 20:00

public class TryCatchText {


public static void main(String[] args) {

TryCatchText tct =new TryCatchText();

int result =tct.text();

System.out.println("方法执行了"+result);


}


public int text(){

int diveder =10;

int result =100;

try{

while (diveder>-1){

diveder--;

result =diveder + result/10;

}

return result;

}catch(Exception e){

e.printStackTrace();

System.out.println("循环抛出异常了");

return -1;

}

}

}


写回答 关注

1回答

  • qq_力克_0
    2016-10-27 20:03:47

    自己刚才弄懂了。浪费了一次提问机会。呜呜

    正在入门的程...

    为什么啊?

    2017-01-17 22:36:08

    共 1 条回复 >

Java入门第三季

Java中你必须懂得常用技能,不容错过的精彩,快来加入吧

409784 学习 · 4339 问题

查看课程

相似问题