This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
Hi, If I declare and define a class inside a method, I can access only the final local variables of the method, isn't it? The reason given in RHE for this is that the object of the class declared inside method should be able to outlive the method and this is possible only if variables that can be accessed from the method are final. But then, I am not able to create/access an object of the class declared inside the method outside the method at all!!! Then, what's the big deal in allowing only final variables of the method to be able to be accessed??? Or is there any way that I can create/access an object of the class declared inside a method outside the method?? Thanks, Aparna
Hi Randall, Thanks for ur reply. But then, such a thing is not discussed even in JLS, where else to look for answers? Everywhere, the examples comfortably declare an object inside the method itself. There has been no example/ no mention of how that object can be accessed outside. Any help from anyone would be well appreciated. Thanks, Aparna