I am currently taking a introductory course in Java and this is regarding try-catch method. When I type this my System.out.println statement keeps repeating endlessly. Here is my code:
public static double exp(double b, int c) { if (c == 0) { return 1; } // c > 0 if (c % 2 == 0) { return exp(b*b, c / 2); } if (c<0){ try{ throw new ArithmeticException(); } catch (ArithmeticException e) { System.out.println("yadonegoofed"); } } // c is odd and > 0 return b * exp(b, c-1); }