Hallo, ich habe erst begonnen zu programmieren und habe eine Frage.
Wieso wird bei diesem Code nur "Dies ist eine ArithmeticException" ausgegeben und nicht "Dies ist eine ArithmeticException" und "Dies ist eine Exception".
public class Rechenfehler {
public static void main(String[] args) {
try{
int i = 0;
System.out.println(5/i);
}catch(ArithmeticException rechenFehler){
System.out.println("Dies ist eine ArithmeticException");
}catch (Exception fehlerException){
System.out.println("Dies ist eine Exception");
}
}
}
Wieso wird bei diesem Code nur "Dies ist eine ArithmeticException" ausgegeben und nicht "Dies ist eine ArithmeticException" und "Dies ist eine Exception".
public class Rechenfehler {
public static void main(String[] args) {
try{
int i = 0;
System.out.println(5/i);
}catch(ArithmeticException rechenFehler){
System.out.println("Dies ist eine ArithmeticException");
}catch (Exception fehlerException){
System.out.println("Dies ist eine Exception");
}
}
}