public class MathsTest { /** * @param args */ public static void main(String[] args) { Maths m = new Maths(); int result = 0; try { m.factorial(-5); m.factorial(5); // Not executed } catch (MathsException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { result = m.factorial(-5); // ... } catch(MathsException me) { // System.err.println(me.getX()); System.err.println("Factorial method failed"); } finally { System.out.println("Inside finally block"); } System.out.println(result); } }