下面的代碼中,我有一個名爲SHIP1整數,其值在倒數計時器對象設置爲5。我想把這個int值放到一個字符串數組中,但是當我將字符串數組的第一行打印到文本視圖中時,ship1AddSpend(整數)就會變成零。爲什麼值不變爲5?有人可以幫忙嗎?爲什麼我的整數值爲零時,我在計數它設置爲5倒定時器
final TimerClass Timer2 = (TimerClass) new TimerClass(500,1000) {
final public int OnFinish()
{
ship1AddSpend = 5;
this.start();
return ship1AddSpend;
}
}.start();
int ship1AddSpend;
final String[] shipDesc = {
"10 Planets Every 5 Secs \n" + ship1AddSpend + "$",
"50 Planets Every 5 Secs \n",
"100 Planets Every 5 Secs \n 1500$",
"500 Planets Every 4 Secs \n 3000$",
"1000 Planets Every 4 Secs \n 7500$",
"5000 Planets Every 4 Secs \n 15000$",
"10000 Planets Every 3 Secs \n 50000$",
"30000 Planets Every 3 Secs \n 100000$",
"60000 Planets Every 3 Secs \n 500000$",
"100000 Planets Every 1 Secs \n 1000000$"};
如果將變量聲明爲volatile類型,會發生什麼? – chrylis 2014-10-05 10:07:16
爲什麼在24小時內你有兩個同樣的問題的帖子? – greenapps 2014-10-05 11:23:49
,因爲第一個沒有得到答案 – 2014-10-05 16:04:01