This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Please let me know how this works out: class Uest{ public static void main (String[]args){ //for (int i=0; i<10; ++i) { try{ try{ //if (i % 3 == 0) throw new Exception("EO"); System.out.println(i); }catch (Exception inner) { i *=2; if(i % 3 ==0) throw new Exception("E1"); } finally { ++i; } }catch (Exception outer) { i += 3; }finally { --i; } } } } When I compile I am getting 4 & 5 as answers, Please help me out in this regard.
Ch. Vijayalakshmi
Vijayalakshmi Chipada
Greenhorn
Joined: Dec 04, 2000
Posts: 17
posted
0
Please help me out in this regard class Uest{ public static void main (String[]args){ //for (int i=0; i<10; ++i) { try{ try{ //if (i % 3 == 0) throw new Exception("EO"); System.out.println(i); }catch (Exception inner) { i *=2; if(i % 3 ==0) throw new Exception("E1"); } finally { ++i; } }catch (Exception outer) { i += 3; }finally { --i; } } } } When compilation I am getting 4 & 5 as answers
Yamuna Pattathil
Greenhorn
Joined: Dec 03, 2000
Posts: 19
posted
0
I have the same code with a lot of sop statements. You can easily understand the program flow. The one with label "original" is the only one you had in your code.
Also note that 0, 3, 6, 9 etc are values of i(<10) which causes if condition to be executed and hence Exception. [This message has been edited by Yamuna Pattathil (edited December 04, 2000).]
saumil shukla
Ranch Hand
Joined: Dec 01, 2000
Posts: 47
posted
0
is there any way to trace this?
Yamuna Pattathil
Greenhorn
Joined: Dec 03, 2000
Posts: 19
posted
0
I have given the output and explanations below
Hope this helps. [This message has been edited by Yamuna Pattathil (edited December 04, 2000).]