I thought I understood what was being asked of me but apparently, I haven't a clue. I don't even know where to begin asking questions. I'm sorry for the vagueness and I hope there is somewhere someone can start with helping me solve this. Thanks in advance!
package com.codegym.task.task09.task0917;
/*
Catching unchecked exceptions
*/
public class Solution {
public static void main(String[] args) {
handleExceptions(new Solution());
}
public static void handleExceptions(Solution obj) {
try {
obj.method1();
obj.method2();
obj.method3();
}
catch (NumberFormatException e) {
printStack(e);
}
catch (IndexOutOfBoundsException e) {
printStack(e);
}
catch(NullPointerException e) {
printStack(e);
}
}
public static void printStack(Throwable throwable) {
System.out.println(throwable);
for (StackTraceElement element : throwable.getStackTrace()) {
System.out.println(element);
}
}
public void method1() {
throw new NullPointerException();
}
public void method2() {
throw new IndexOutOfBoundsException();
}
public void method3() {
throw new NumberFormatException();
}
}