Could someone tell me what is wrong here
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();
} catch (Exception e) {
e.printStackTrace();
System.out.println("NullPointerException");
}
try {
obj.method2();
} catch (Exception e) {
System.out.println("IndexOutOfBoundsException");
e.printStackTrace();
}
try {
obj.method3();
} catch (Exception e) {
System.out.println("NumberFormatException");
e.printStackTrace();
}
}
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();
}
}