In the Android development just learned that the onclick of button is implemented by the way of local inner class, the concrete principle I will understand later, just encounter problems always want to know why, do not tell me this is the rule, die remember on it.
The problem is that the local inner class is defined in the method, why the variables in the method are used, only the final decoration is used?
That's what I guess.
Local inner class, no matter where the family is a class ah, define a class, you can access the members of other classes, well, I have no idea, but to access the members of the family members of the method, this is a bit too much. is not at all a scope, the function of the variable life cycle is too short, if you can access, then the function of the variables are stacked, in case the reference to the creation of the inner class object is still alive. That's a lot of embarrassment. Do not think that you are in that method of writing can be accessed, you are also a class AH. So why do you add the final modifier to the constants to access it? Final modification is a constant, is a constant with a name, the constant is immutable, since it is a constant write final int x=3; Writing x elsewhere is the same as 3. Since the same I write 3 x, anyway x will not change. For computers, remember that x is not as direct as 3.
Java local inner class