由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - Why inner classes can access only local final variables?
相关主题
问一个java的面试题 (转载)java inner class - 初学者问
inner class 让认糊涂感觉inner class挺好用的
multiple classes in one file:revistedTo call main method from another class
Re: help: how does the class Model$5.class come?问个基本问题
关于inner class的继承access java parent class protected variable question
[合集] java 得 inner class 有没有 static 有什么区别啊?请教:怎么把synchronize的method改成用thread 但thread safe呢?
请教一个有关 inner class 的问题JavaBean variable name standard
static final的问题how to solve the problem: the members change by each other .
相关话题的讨论汇总
话题: variables话题: modifiable话题: why话题: final话题: inner
进入Java版参与讨论
1 (共1页)
y***y
发帖数: 224
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更像一个硬性规定?
e*****t
发帖数: 1005
2
http://stackoverflow.com/questions/1299837/cannot-refer-to-a-no
ble-inside-an-inner-class-defined-in-a-differen

,

【在 y***y 的大作中提到】
: 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更像一个硬性规定?

1 (共1页)
进入Java版参与讨论
相关主题
how to solve the problem: the members change by each other .关于inner class的继承
Jar question[合集] java 得 inner class 有没有 static 有什么区别啊?
问一简单的问题 关于import请教一个有关 inner class 的问题
Answer to "Is this a Bug or not? "static final的问题
问一个java的面试题 (转载)java inner class - 初学者问
inner class 让认糊涂感觉inner class挺好用的
multiple classes in one file:revistedTo call main method from another class
Re: help: how does the class Model$5.class come?问个基本问题
相关话题的讨论汇总
话题: variables话题: modifiable话题: why话题: final话题: inner