Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 创建结构实例两次_Android_Class_Structure - Fatal编程技术网

Android 创建结构实例两次

Android 创建结构实例两次,android,class,structure,Android,Class,Structure,我有以下代码: Tile tile[] = new Tile [40]; for(int i; i<40; i++) tile[id]= new Tile(); Tile Tile[]=新Tile[40]; for(int i;i) 完全可以,当您第二次运行for循环时,新数据将覆盖添加到磁贴数组中的所有旧数据结构 Is it a good thing to do or not? 如果您仍在平铺数组中使用一些旧数据,那么它将被新数据替换,从而产生意外的结果 另一方面,如果您不使用一些旧

我有以下代码:

Tile tile[] = new Tile [40];
for(int i; i<40; i++) tile[id]= new Tile();
Tile Tile[]=新Tile[40];
for(int i;i)
完全可以,当您第二次运行
for循环
时,新数据将覆盖添加到
磁贴
数组中的所有旧数据结构

Is it a good thing to do or not?
如果您仍在
平铺
数组中使用一些旧数据,那么它将被新数据替换,从而产生意外的结果


另一方面,如果您不使用一些旧数据,并且希望将所有数据规范化为新状态,则需要再次运行循环。

您的意思是再次运行for循环?非常感谢您的回答。
Is it a good thing to do or not?