我有以下方法应该返回一个31行的数组(每行有31个索引)。这里是我的代码:如何用增量行和固定数量的索引创建一个数组
public static int[] funcA (int[] arrayB,int[] arrayC){
int d,i;
int [] arrayA = new int[31];
int [] arrayD= new int[31];
for (d=0; d<31; d++){
int []temp = new int[31];
for (i=0; i<31; i++){
arrayA [i] = arrayB[i]^arrayC[i];
}
// at this point, 31 values are generated inside the arrayA.
// my problem is here: the 31 values of arrayA should be assigned to arrayD in row[d](the row has 31 indexes)
// then, an operation occur to arrayC and the values of arrayA are changed
}
return arrayD;
}
如何做到这一点?如何创建具有两个维度的arrayD,并在每次arrayA发生变化时(将数组A的arrayA的历史记录存储在arrayD中,因此每个数据行都在D中)将31个值(arrayA)传递给一行(31个索引)代表A)的不同状态?
而且你的代码试图... – 2013-04-27 15:14:51
这真的没有明确发生了什么事情,特别是你永远做什么用tempArray ... – 2013-04-27 15:16:22
@ LuiggiMendoza:事情是:非他们工作,我不保留代码不起作用,对不起(我明白我们的关注)。然而,在写这个问题后:我想知道是否有一种方法可以将我的arrayA保存为一个公共变量,就像在C++中一样? – 2013-04-27 15:18:30