From 530141c542ab3b44991f05016e66db651795e9c9 Mon Sep 17 00:00:00 2001 From: Kamal Wickramanayake Date: Sat, 21 Feb 2026 20:33:23 +0530 Subject: Added java/collections and java/error handling sample code --- java/12-error-handling-2/MathsTest7.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 java/12-error-handling-2/MathsTest7.java (limited to 'java/12-error-handling-2/MathsTest7.java') diff --git a/java/12-error-handling-2/MathsTest7.java b/java/12-error-handling-2/MathsTest7.java new file mode 100644 index 0000000..f55cfad --- /dev/null +++ b/java/12-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); + } + +} -- cgit v1.2.3