java异常问题

lv6917527 lv6917527 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
1///
package sim;

public class NeedCleanup {
private static long counter=1;
private final long id = counter++;
public void dispose(){
System.out.println("NeedsCleanup"+id+"dispised");
}
}
class ConstructionException extends Exception{}

class NeedCleanup2 extends NeedCleanup{
public NeedCleanup2() throws ConstructionException{}
}


2///
package sim;

public class CleanIdiom {
public static void main(String[] args) {
NeedCleanup nc1 = new NeedCleanup();
try{

}finally{
nc1.dispose();
}
NeedCleanup nc2 = new NeedCleanup();
NeedCleanup nc3 = new NeedCleanup();
try{

}finally{
nc3.dispose();
nc2.dispose();
}
try{
NeedCleanup2 nc4 = new NeedCleanup2();
try{
NeedCleanup2 nc5 = new NeedCleanup2();
try{

}finally{
nc5.dispose();
}
}catch(ConstructionException e){
System.out.println(e);
}finally{
nc4.dispose();
}
}catch(ConstructionException e){
System.out.println(e);
}
}

}



看不懂这个,跑单步也看不懂,求网友们解释一下,谢谢了。
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
lv6917527
Java EE 67,535 成员 225,843 内容