what i can't understand here is that the finally block runs twice - how is this ? I thought a finally code could only run once - is this because they are tied into nested try blocks ? is it that because one try block is nested it can run finally completely independent of the enclosing try block, so both finally blocks run ? or am i in the wrong ball park altogether ?
My thanks in advance.
PS Where i'm located over the next couple of days means at best i'll only have intermittent internet access, so forgive if an immediate reply isn't received (probably won't be able to get back online until 5/6 this afternoon/evening.
If that is an exam question, we might have to delete this thread, but not if it is a publicly‑available sample. A lot of questions use such poor code style to try and confuse readers. It appears to work
fred rosenberger wrote:PLEASE format your code properly. What you posted above it a hot mess, and next to impossible to read.
I could be mistaken but I think that question is taken directly from one of the SCJP exam sample questions and that is exactly how it is formatted.... pure evil...
my apologies I should have worded my reply more carefully. I meant to say the "SCJP exam preparation book" being one of the questions on flow control. I think it is the Kathy Sierra, Bert Bates Text.
Joined: May 29, 2012
thanks everyone for your replies. Peter, it is that ocjp preparation book, i'm going through the self test questions and finding some very tricky so i hoped to get some help on the forum here. is it ok to put them up ? i have four/five more i'm having trouble with. ideally, is there a thread on which these questions have already been discussed ?
I don’t know whether there are threads about those questions, but you can try putting part of the question into our search box. You probably will find something, because lots of people use those books and are bound to have had the same problems. Remember to include the forum named after the exam (maybe this one?) in the search options, because that is where you are most likely to find something.
Yes, you can post your question, but be sure to acknowledge the origin of the question.
jay sugrue wrote:thanks everyone for your replies. Peter, it is that ocjp preparation book, i'm going through the self test questions and finding some very tricky so i hoped to get some help on the forum here. is it ok to put them up ? i have four/five more i'm having trouble with. ideally, is there a thread on which these questions have already been discussed ?
As long as you quote your sources (and a little better than what you did so far), it should not be an issue. See this link for full details....
Thanks for the replies Campbell and Henry, I'll do that and Henry, yes, I see now what you mean about the formatting. Forgive me, this is what I've been looking at for a few months now and I've no previous experience in Java or any other programming language. I actually think it looks nice and neat that way, ha ! But yeah I'll format in future.