In the code the handleExceptions method is calling method1, method2 and method3.
I am using one try catch block
The catch statement is catching and printing what exceptions are caught.
Therefore not sure what the actual issue could be that's causing the validation to fail
Please advise.
package com.codegym.task.task09.task0916;
import java.io.IOException;
import java.rmi.RemoteException;
/*
Catching checked exceptions
*/
public class Solution {
public static void main(String[] args) throws IOException, NoSuchFieldException {
handleExceptions(new Solution());
}
public static void handleExceptions(Solution obj) throws IOException, NoSuchFieldException {
obj.method1();
obj.method2();
obj.method3();
try{
obj.method1();
obj.method2();
obj.method3();
}
catch(Exception e){System.out.println(e);
}
}
public void method1() throws IOException {
throw new IOException();
}
public void method2() throws NoSuchFieldException {
throw new NoSuchFieldException();
}
public void method3() throws RemoteException {
throw new RemoteException();
}
}