大家猜猜结果是什么?

binny 2003-05-02 10:23:11
==========C.class==============

public class C {

public static void main(String[] aa) throws myException{

C c = new C();

c.doIt();
}

// public boolean doIt() throws myException {
public void doIt() throws myException {
A a = new A();
try{
a.dothrow();
} catch (myException e) {
try{
a.dothrow();
} catch (myException e1) {
throw new myException();
// return true;
}

} finally {
//return false;
throw new myException();
}

}
}
==========A.class==============

class A {
public void dothrow() throws myException {
throw new myException();
}
}

=========myException.class=====

class myException extends Exception {

}

大家猜猜结果是什么?Exception 是从哪里抛出来的?如果把Exception改为boolean,那最后的返回结果是什么?

希望大家先想想再运行
...全文
53 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
farawayMemory 2003-05-06
  • 打赏
  • 举报
回复
return false
sallina 2003-05-02
  • 打赏
  • 举报
回复
} finally {
//return false;
throw new myException();
}
awfe 2003-05-02
  • 打赏
  • 举报
回复
finally

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧