Created
December 4, 2015 10:29
-
-
Save ProZhar/85708fea00d9c5acd5bb to your computer and use it in GitHub Desktop.
com.javarush.test.level09.lesson08.task04
This file contains hidden or 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 (IOException | NoSuchFieldException 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(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment