2017-06-23 1 views

Antwort

2

Wie Oracle doc sagt

Chained Exception Facility 

Es ist üblich, dass Java-Code eine Ausnahme zu fangen und eine andere

werfen Und hier ein Beispiel aus TutorialsPoint:

public class Main{ 
    public static void main (String args[])throws Exception { 
     int n = 20, result = 0; 
     try { 
     result = n/0; 
     System.out.println("The result is"+result); 
     } catch(ArithmeticException ex) { 
     System.out.println ("Arithmetic exception occoured: "+ex); 
     try { 
      throw new NumberFormatException(ex); 
     } catch(NumberFormatException ex1) { 
      System.out.println ("Chained exception thrown manually : "+ex1); 
     } 
     } 
    } 
}