[英]Looping into 2d Object array
Object [][] data = new Object[4][4] ; 对象[] []数据=新对象[4] [4];
for (int i =0;i<data.length;i++)
{
data[i]={"a","b","c","d"};
}
is there any way to fill the 2 day array with a way similar to that, NOTE: a ,b,c and d are different data so i can't use 2 loops to fill the array i 'm searching to a close way to that 有没有办法用类似的方法来填充2天数组,注意:a,b,c和d是不同的数据,所以我不能使用2个循环来填充数组,我正在寻找一种接近的方法那
when i tried to do 当我尝试去做
data[i]={"a","b","c","d"};
i thought it was going to work but for a reason it didn't 我以为它会工作,但由于某种原因没有
You need to use "new" or give the indexes 您需要使用“新”或提供索引
Something like this: 像这样:
data[i]= new Object[]{"a","b","c","d"};
or 要么
data[i][0] = "a";
data[i][1] = "b";
data[i][2] = "c";
data[i][3] = "d";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.