异常三层结构

package src;
//异常三层结构
public class san {
public static void main(String[] args) {
In in=new In();
in.gao();
}
}
class hao extends Exception{
hao(){}
hao(String name){
super(name);
}
}
class di extends Exception{
di(){}
di(String name){
super(name);
}
}
class In{
public void d(int a)throws di{
if(a>50){
System.out.println("运行正常");
}else{
System.out.println("报告错误 请求中级处理");
throw new di("上传给上级");
}
}
public void zhong()throws hao{
try{
int a=50;
System.out.println("上传a"+a);
this.d(a);
}catch(di e){
System.out.println(e);
System.out.println("中级处理");
throw new hao("上传给高级");
}
}
void gao(){
try{
this.zhong();
}catch(hao e){
System.out.println(e);
System.out.println("处理成功");
}
}
}

posted @ 2017-12-25 10:34  zhouwen周文  阅读(82)  评论(0编辑  收藏  举报