![]() |
1
7
您可以通过简单地反编译内部类来注意下面发生的事情。下面是一个简短的例子: After compiling this piece of code:
你会得到
还可以注意到,内部类有一个字段。
|
![]() |
2
9
|
![]() |
3
8
No method can access local variables of other methods. This includes methods of anonymous classes as the one in your example. 也就是说,
写作
|
![]() |
4
2
这个内部类被翻译成类似于:
由于内部类实际上得到了最终变量的一个副本,因此它不能对其进行任何在外部类中可见的更改。若要禁止,即使尝试更改此参数,也只允许访问内部类中的最终变量。 |