diff options
Diffstat (limited to 'java/12-error-handling-2/MathsTest3.java')
| -rw-r--r-- | java/12-error-handling-2/MathsTest3.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/java/12-error-handling-2/MathsTest3.java b/java/12-error-handling-2/MathsTest3.java new file mode 100644 index 0000000..ca45e5c --- /dev/null +++ b/java/12-error-handling-2/MathsTest3.java @@ -0,0 +1,21 @@ +public class MathsTest3 { + + /** + * @param args + */ + public static void main(String[] args) { + Maths m = new Maths(); + int result = 0; + + try { + result = m.factorial(-5); + } catch(MathsException e) { + System.err.println("Factorial method failed"); + System.err.println(e.getMessage()); + e.printStackTrace(); + } + + System.out.println(result); + } + +} |
