summaryrefslogtreecommitdiff
path: root/java/11-error-handling-2/MathsTest7.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/11-error-handling-2/MathsTest7.java')
-rw-r--r--java/11-error-handling-2/MathsTest7.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/java/11-error-handling-2/MathsTest7.java b/java/11-error-handling-2/MathsTest7.java
new file mode 100644
index 0000000..f55cfad
--- /dev/null
+++ b/java/11-error-handling-2/MathsTest7.java
@@ -0,0 +1,22 @@
+public class MathsTest7 {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ Maths m = new Maths();
+ int result = 0;
+
+ try {
+ result = m.factorial(-5);
+ } catch(MathsException me) {
+ System.err.println("Factorial method failed");
+ return;
+ } finally {
+ System.out.println("Inside finally block");
+ }
+
+ System.out.println(result);
+ }
+
+}