Les Morgan wrote:write some code and see the execution of what happens when an exception is thrown, you do go to the catch to evaluate it, so execution is transferred immediately to the catch statement to be evaluated.
Mark Kevin wrote:Thanks, Les, although it seems as though in both cases execution transfers immediately - coming from the try block - so that word shouldn't control. What seems to me to matter more is where control immediately lands from the try, which is the catch() - a mandatory step in the execution of the catch block.
Mark Kevin wrote:These two statements conflict. In other words, on page 337 execution should transfer to line 7, not line 8. Otherwise there is a contradiction between p. 337 and p. 336. Or maybe it's wrong on page 336. I don't know.
The line of the catch block itself could/should be considered as NOOP. It's only an indication of which exceptions will be handled by that catch block. As far as I know you can't add any statement to that line to do something useful (like printing a message).
Mark Kevin wrote:As such, I always regarded the part "Exception e" as a statement. That's what I learned in the book. It's a declared method variable similar to, say, an instance variable like "private String words;
Mark Kevin wrote:Of course you don't add anything to that e variable within the method (between the parentheses) but that object reference e can be used in the block to display the message (e.getMessage()) or you can override its toString() and create your own message (or do other things).
Mark Kevin wrote:Line 7, not line 8 begins the control and execution.
Roel De Nijs wrote:Anyway my suggestion would be to change page 337, something like "execution transfers to that exception handler (line 7 in the code)"; then both statements are more or less equivalent.