Created
February 13, 2019 13:42
-
-
Save NickBaynham/76e0e04ef98cdd363c20ac02593b4ddd to your computer and use it in GitHub Desktop.
Exceptions
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 codingExamples; | |
import org.junit.Test; | |
public class Exceptions2 { | |
@Test | |
public void test() { | |
System.out.println(doIt()); | |
} | |
private int doIt() { | |
int i = 0; int j = 0; | |
try { | |
int k = i / j; | |
} catch (ArithmeticException e) { | |
return -1; | |
} catch (RuntimeException r) { | |
return 0; | |
} finally { | |
System.out.println("Done."); | |
} | |
return 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output:
Done.
-1