Набирал методом тыка, но вроде нет одинаковых названий. Чего Валидатор матюкается?
package com.javarush.task.task14.task1419;
import java.util.ArrayList;
import java.util.EmptyStackException;
import java.util.List;
import java.util.NoSuchElementException;
/*
Нашествие исключений
*/
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 (Exception e) {
exceptions.add(e);
}
Exception e1 = new NullPointerException("e1");
exceptions.add(e1);
Exception e2 = new IllegalArgumentException("e2");
exceptions.add(e2);
Exception e3 = new IndexOutOfBoundsException("e3");
exceptions.add(e3);
Exception e4 = new ArrayStoreException("e4");
exceptions.add(e4);
Exception e5 = new NumberFormatException("e5");
exceptions.add(e5);
Exception e6 = new IllegalAccessException("e6");
exceptions.add(e6);
Exception e7 = new NoSuchElementException("e7");
exceptions.add(e7);
Exception e8 = new IllegalArgumentException("e8");
exceptions.add(e8);
Exception e9 = new NegativeArraySizeException("e9");
exceptions.add(e9);
//напишите тут ваш код
}
}