Why inner classes can access only local final variables?# Java - 爪哇娇娃
y*y
1 楼
From wiki:
This is because the local class instance must maintain a separate copy of
the variable, as it may out-live the function; so as not to have the
confusion of two modifiable variables with the same name in the same scope,
the variable is forced to be non-modifiable
感觉必须加final更像一个硬性规定?
This is because the local class instance must maintain a separate copy of
the variable, as it may out-live the function; so as not to have the
confusion of two modifiable variables with the same name in the same scope,
the variable is forced to be non-modifiable
感觉必须加final更像一个硬性规定?