Last active
November 6, 2019 11:01
-
-
Save semlinker/117dd87ef97a846cb22cb332cb5d1b99 to your computer and use it in GitHub Desktop.
Java try-catch-finally
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
public class FinallyTest { | |
public void foo() { | |
try { | |
tryItOut(); | |
} catch (MyException e) { | |
handleException(e); | |
} finally { | |
handleFinally(); | |
} | |
} | |
private void tryItOut() throws MyException { | |
} | |
class MyException extends Exception { | |
} | |
private void handleException(MyException e) { | |
} | |
private void handleFinally() { | |
} | |
} |
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
public class MultiException { | |
public void foo() { | |
try { | |
tryItOut(); | |
} catch (MyException e) { | |
handleException(e); | |
} catch (MyException1 e) { | |
handleException1(e); | |
} | |
} | |
private void tryItOut() throws MyException, MyException1 { | |
} | |
class MyException extends Exception { | |
} | |
class MyException1 extends Exception { | |
} | |
private void handleException(MyException e) { | |
} | |
private void handleException1(MyException1 e) { | |
} | |
} |
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
public class OneException { | |
public void foo() { | |
try { | |
tryItOut(); | |
} | |
catch (MyException e) { | |
handleException(e); | |
} | |
} | |
private void tryItOut() throws MyException { | |
} | |
class MyException extends Exception { | |
} | |
private void handleException(MyException e) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment