【发布时间】:2014-10-04 19:19:31
【问题描述】:
在下面的代码中,我有一个名为 ship1 的整数,它的值在倒数计时器对象中设置为 5。我想将此 int 值放入一个字符串数组,但是当我这样做并将字符串数组的第一行打印到文本视图中时,ship1AddSpend(整数)出现为零。为什么值没有变为 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$"};
【问题讨论】:
-
因为你没有同步。
-
这是什么意思,你能解释一下你的答案吗?
-
I have an integer called ship1。在哪里?when I print the first line of the string array。你什么时候这样做?你知道int ship1AddSpend;。将其更改为int ship1AddSpend=33;。然后告诉我们您现在获得的价值。