Created
April 24, 2015 18:36
-
-
Save ZhdanRuslan/c4cf60228fa5e2b196b5 to your computer and use it in GitHub Desktop.
level09.lesson08.task04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level09.lesson08.task04; | |
import java.io.IOException; | |
import java.rmi.RemoteException; | |
/* Перехват checked исключений | |
В методе processExceptions обработайте все checked исключения. | |
Нужно вывести на экран каждое возникшее checked исключение. | |
Можно использовать только один блок try.. | |
*/ | |
public class Solution { | |
public static void main(String[] args) { | |
processExceptions(new Solution()); | |
} | |
public static void processExceptions(Solution obj) { | |
try{ | |
obj.method1(); | |
obj.method2(); | |
obj.method3(); | |
} catch (NoSuchFieldException exc){ | |
System.out.println(exc); | |
} catch (RemoteException exc){ | |
System.out.println(exc); | |
} catch (IOException exc){ | |
System.out.println(exc); | |
} | |
} | |
public void method1() throws IOException { | |
throw new IOException(); | |
} | |
public void method2() throws NoSuchFieldException { | |
throw new NoSuchFieldException(); | |
} | |
public void method3() throws RemoteException { | |
throw new RemoteException(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment