Wydaje mi się, że robię zgodnie z zdaniem.
Jednak
catch(Exception e)
{
System.out.println("RemoteException"); // tego mi nie przyjmuje, gdyż stwierdza, że ten wyjątek jest już obsługiwany.
}
Co jest nie tak?
I think I'm doing as I think.
But
catch (Exception e)
{
System.out.println ( "RemoteException"); // does not accept this because it states that this exception is already supported.
}
What is wrong?
package pl.codegym.task.task09.task0916;
import java.io.IOException;
import java.rmi.RemoteException;
/*
Obsługiwanie wyjątków typu checked
*/
public class Solution
{
public static void main(String[] args)
{
obslugaExceptions(new Solution());
}
public static void obslugaExceptions(Solution obj)
{
try
{
obj.method1();
obj.method2();
obj.method3();
}
catch (IOException e)
{
System.out.println("IOException");
}
catch(NoSuchFieldException e)
{
System.out.println("NoSuchFieldException");
}
catch(Exception e)
{
System.out.println("RemoteException");
}
}
public void method1() throws IOException
{
throw new IOException();
}
public void method2() throws NoSuchFieldException
{
throw new NoSuchFieldException();
}
public void method3() throws RemoteException
{
throw new RemoteException();
}
}