Hello, I have two codes that I think are functionally identical, and I need help understanting why one is validated and the other is not.
Here is NOT working code (ERROR : The program must catch a specific type of exception, not all possible exceptions (i.e. not Exception)) :
public class Solution {
public static void main(String[] args) throws Exception {
try {
int a = 42 / 0;
} catch (java.lang.ArithmeticException e) {
stuff that i wont spoil because of help section rules
}
}
}
Here is working code :
public class Solution {
public static void main(String[] args) throws Exception {
try {
int a = 42 / 0;
} catch (ArithmeticException e) {
stuff that i wont spoil because of help section rules
}
}
}
If I haven't misunderstood java so far, these are doing exactly the same thing and should pass the test the same way.