No matter I do the second exception I throw on line 32 is Unreachable Statement on IntelliJ, it doesn't compile...
package com.codegym.task.task14.task1419;
import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException;
import java.awt.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.IllegalFormatFlagsException;
import java.util.List;
/*
Exception invasion
*/
public class Solution {
public static List<Exception> exceptions = new ArrayList<Exception>();
public static void main(String[] args) {
initExceptions();
for (Exception exception : exceptions) {
System.out.println(exception);
}
}
private static void initExceptions() { // The first exception
try {
float i = 1 / 0;
throw new ClassNotFoundException();
throw new InstantiationException();
throw new NoSuchFieldException();
throw new NoSuchMethodException();
throw new IllegalThreadStateException();
throw new NumberFormatException();
throw new ArrayIndexOutOfBoundsException();
throw new StringIndexOutOfBoundsException();
throw new SecurityException();
}
catch (ClassNotFoundException a) {
exceptions.add(a);
}
catch (InstantiationException c) {
exceptions.add(c);
}
catch (NoSuchFieldException d) {
exceptions.add(d);
}
catch (NoSuchMethodException e) {
exceptions.add(e);
}
catch (IllegalThreadStateException f) {
exceptions.add(f);
}
catch (NumberFormatException g) {
exceptions.add(g);
}
catch (ArrayIndexOutOfBoundsException h) {
exceptions.add(h);
}
catch (StringIndexOutOfBoundsException t) {
exceptions.add(t);
}
catch (SecurityException s) {
exceptions.add(s);
}
catch (Exception b) {
exceptions.add(b);
}
}
}