This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Don't you think the code should be modified in order to print any value of i?
The spelling of "AritmeticException" should be "Arithmetic Exception". The return statement should appear after finally clause in order to compile the program. In this case the output of the program shall be "exception /by zero", "Its all over..i'm quitting" and 6. The program continues the execution of the main method after the execution of the try/catch/finally statement. I hope your question was intended to produce the above output. The program wont compile in its original version.
[This message has been edited by maha anna (edited April 01, 2000).]
Joined: Nov 22, 2008
you can also put "return z" inside the finally block instead of outside the finally block. In case of methods that return a value all the paths of execution should either return a value or throw an exception in order for it to compile. This program shall also compile if the method throws a new exception in the end.