Hey,
I have no idea what I'm doing wrong :D
package pl.codegym.task.task14.task1419;
import com.sun.nio.sctp.IllegalReceiveException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.nio.channels.IllegalChannelGroupException;
import java.util.*;
/*
Inwazja wyjątków
*/
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() { // Pierwszy wyjątek
try {
float i = 1 / 0;
} catch (Exception e) {
exceptions.add(e);
}
try {
int g = -2;
} catch (IllegalArgumentException e) {
exceptions.add(e);
}
try {
int num[] = {1, 2, 3, 4};
System.out.println(num[5]);
} catch (ArrayIndexOutOfBoundsException e) {
exceptions.add(e);
}
try {
File file = new File("E://file.txt");
FileReader fr = new FileReader(file);
} catch (FileNotFoundException e) {
exceptions.add(e);
}
try {
float e = 5 / 0;
} catch (IllegalReceiveException e) {
exceptions.add(e);
}
try {
float d = 6 / 0;
} catch (IllegalThreadStateException e) {
exceptions.add(e);
}
try {
float i = 7 / 0;
} catch (IllegalFormatCodePointException e) {
exceptions.add(e);
}
try {
float c = 8 / 0;
} catch (IllegalFormatPrecisionException e) {
exceptions.add(e);
}
try {
float b = 9 / 0;
} catch (IllegalChannelGroupException e) {
exceptions.add(e);
}
try {
float a = 10 / 0;
} catch (IllegalFormatFlagsException e) {
exceptions.add(e);
}
}
}