This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
In K&B 6, Ch.8 p.671 (Method-Local Inner Classes) it states that the Inner Class Object can't use the local variables of the method that it's in
Because the local variables aren't guaranteed to be alive as long as the method-local inner class object... ...Unless the local variables are marked final.
I don't understand why marking the local variable as final would make a difference. My understanding is that marking an object reference variable as final means that you can't assign another object to that reference variable, but it has no effect on the variable's scope.
I can understand the first output as the StringBuilder object 'bob' is on the stack. But surely after the go() method has run, the stack frame is popped from the stack (if thats the right terminology) and no reference to 'bob' exists. So when the goAgain() method runs, I'm not sure how the doStuff method manages to access an object to which no reference exists. But it does, so there's something I'm not understanding here.