This might be a really dumb question to most of you here, really sorry about that. I am new to java and the book i am reading didn't explain the working of an example in it.
public class CrazyWithZeros { public static void main(String[] args) { try { int answer = divideTheseNumbers(5, 0); } catch (Exception e) { System.out.println("Tried twice, " + "still didn't work!"); } } public static int divideTheseNumbers(int a, int b) throws Exception { int c; try { c = a / b; System.out.println("It worked!"); } catch (Exception e) { System.out.println("Didn't work the first time."); c = a / b; System.out.println("It worked the second time!"); } finally { System.out.println("Better clean up my mess."); } System.out.println("It worked after all."); return c; } }
I can't figure out where the control will go after another exception is generated in catch block in divideTheseNumbers() method ? Any help will be appreciated !
divideTheseNumbers.divideTheseNumbers()method throws an exception then whee the catch block inside the method?