标签:
/*class FuShuException extends Exception { FuShuException(String msg) { super(msg); } } class SubFuShuException extends FuShuException { SubFuShuException(String msg) { super(msg); } } class OtherException extends Exception { OtherException(String msg) { super(msg); } } class FuDemo { public int div(int a) throws SubFuShuException { if(a<0) throw new SubFuShuException("出现了负数的情况。"); return a; } } class Demo extends FuDemo { public int div(int a,int b) throws SubFuShuException { if(b<=0) throw new SubFuShuException("出现了非正数"); return a/b; } } class ExceptionDemo5 { public static void main(String args[]) throws FuShuException { Demo d=new Demo(); try { int x=d.div(4,-1); System.out.println(x); } catch (FuShuException e) { System.out.println(e.toString()); } finally { System.out.println("over"); } } }
标签:
原文地址:http://blog.csdn.net/iemdm1110/article/details/51356856