posted 19 years ago
Hi Wil,
Welcome to JavaRanch!
Consider the "life cycle" of a method: It's called, it executes, and it exits.
While executing, local variables might be created within the method. But since the scope of these variables is limited to the method, they are typically destroyed when the method exits.
Now suppose that a class is defined within the method. It's certainly possible that an instance of that class will outlive the method in which it's defined. And if that instance is accessing local method variables, there will be a problem when the method exits and those variables no longer exist.
On the other hand, if those method variables are final, then their values can be copied into the instance. That way, when the method exits and local variables are destroyed, copies of their values will remain accessible within the instance. But this is only feasible if the variables are final, because otherwise there would be no guarantee that values copied into the instance would remain correct.
[ January 09, 2006: Message edited by: marc weber ]
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org