how to add exceptions to arraylist?
package com.codegym.task.task14.task1419;
import java.io.IOException;
import java.util.ArrayList;
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;
}
catch (TypeNotPresentException e){
exceptions.add(e);
}
catch (SecurityException e){
exceptions.add(e);
}
catch (EnumConstantNotPresentException e){
exceptions.add(e);
}
catch (IllegalStateException e){
exceptions.add(e);
}
catch (UnsupportedOperationException e){
exceptions.add(e);
}
catch (NumberFormatException e){
exceptions.add(e);
}
catch (ClassCastException e) {
exceptions.add(e);
}
catch (ArithmeticException e) {
exceptions.add(e);
}
catch (RuntimeException e){
exceptions.add(e);
}
catch (Exception e) {
exceptions.add(e);
}
}
}