Hi,
I thought this would be valid, catch multiple exceptions and throw the same again as below.
Did I do anything wrong here?
public class debug {
public static void main(String[] argvs) {
int abc = 123;
try {
int def = 0;
def= abc / 0;
int[] a = new int[2];
for (int i = 1; i <= a.length; i++) {
a[i] = i;
System.out.println(i);
}
}
catch (ArrayIndexOutOfBoundsException | ArithmeticException ex) {
throw ex;
//System.out.println("It doesn't work");
}
catch (Exception ex) {
System.out.println("It works!!");
}
}
}