作者g548462 (里长伯)
看板AndroidDev
标题[问题] final宣告
时间Wed Aug 24 17:43:09 2011
我看书的程式如下(盖索林那本)
public static final String PREF_HEIGHT="BMI_HEIGHT";
protected void onPause()
{
super.onPause();
Log.v(TAG, "onPause");
SharedPreferences setting=getSharedPreferences(PREF,0);
Editor editor=setting.edit();
editor.putString(PREF_HEIGHT, cmInput.getText().toString());
editor.commit();
}
我问题是..宣告成final不是不能变更的嘛!?
为什麽可以输入的东西存在里面?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 163.25.118.131
1F:→ kenliner:...他并没有改变变数的内容 08/24 17:48
2F:推 ericinttu:Editor putString (String key, String value) 08/24 17:56
3F:→ ericinttu:key: The name of the preference to modify. 08/24 17:57
4F:→ ericinttu:value: The new value for the preference. 08/24 17:57
5F:推 LPH66:有点像是 a[x]=y 我们改的是 a[x] 不是 x 这种感觉 08/24 19:59
6F:→ ppaass:变数宣告成final只是不能改变它的参考,不是不能呼叫方法. 08/24 22:14
7F:→ g548462:感谢.. 08/25 16:36