я следующий класс:RuntimeException и ArithmeticException Java
public class TryCatchExample {
public static void main(String[] args) {
try {
System.out.println(1/0);
}catch (RuntimeException e) {
System.out.println("Runtime exception");
} catch (ArithmeticException e) {
System.out.println("Trying to divide by 0 is not ok.");
}
finally {
System.out.println("The program will now exit");
}
}
}
Компилятор выдает эту ошибку:
TryCatchExample.java:10: error: exception ArithmeticException has already been caught
} catch (ArithmeticException e) {
^
1 error
Почему это происходит? ArithmeticException - это подмножество RuntimeException, поэтому это будет бросать исключение RuntimeException или исключение ArithmeticException?
Спасибо!