java中异常注意的细节2

class A extends Exception{
     A(){
	    super();
	 }
	 A(String msg){
	    super(msg);
	 }
}

class B extends A{
     B(){
	    super();
	 }
	 B(String msg){
	    super(msg);
	 }
}

public class Test{
   public static void main(String[] args){
       try{
	      throw new B();
	   }catch(A e){
	      System.out.println("A");
	   }catch(B e){//编译挂了知道不?异常中发生多态时一定要注意要将父类的异常写在下边!
	      System.out.println("B");
	   }catch(Exception e){
	      System.out.println("Exception");
	   }
   }
}

  

java中异常注意的细节2,布布扣,bubuko.com

java中异常注意的细节2

上一篇:[Javascript] What is JavaScript Function Currying?


下一篇:渗透测试-信息收集-c段收集