private static void initExceptions() { // The first exception
try {
float i = 1 / 0;
}
//write your code
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);
}
package com.codegym.task.task14.task1419;
import javax.management.RuntimeErrorException;
import java.util.ArrayList;
import java.util.List;
/*
Exception invasion
1. The list exceptions must contain 10 elements.
2. All items in the list exceptions must be exceptions (descendants of the Throwable class).
3. All items in the list exceptions must be unique.
4. The initExceptions method must be static.
*/
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;
}
//write your code
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);
}
}
}