/* * Eine Methode kann eine Exception auslösen * Die Behandlung erfolgt in der aufrufenden Methode */ class Killer5 { // Methode kann ein ArithmeticException auslösen static int divide(int a, int b) throws ArithmeticException { return (a/b); } public static void main (String [] args) { // Exception Handling für die Methode try { System.out.println ("1/0 = "+divide(1,0)); } catch(Exception e) { System.out.println("I caught the Exception: "+e.getMessage()); } System.out.println("Life goes on!"); } }